0
Answered

Is there a way to keep character away from crosshairs while aiming?

Zachary Lawton 3 months ago in Game Creator updated 3 months ago 4

Hello all,

I'm pretty new to Game Creator, and I have been working on a third-person shooter. I use an adventure cam as my main camera. When aiming down sights, there is no option to change zoom level of the camera through an action, so I change the camera offset to get closer. The problem is, when I move my character while aiming, it can go right in front of the reticle, which completely blocks the view. I have tried a number of different methods, however none have worked. I have listed the ones that got the closest below.

Method 1: Fixed Camera

I created a fixed camera that is swapped to when you aim. Fixed camera attached to the player on an offset seemed to reduce the amount the character moved around the screen. The problem is, this camera can not orbit, and I could not find a way to replicate orbiting for it through rotation locks or anything else.

Method 2: FPS Camera

This may sound counterintuitive, however, by showing the character model and placing the FPS camera on an offset behind the character, it keeps the character from running around the screen, and it can orbit. While this was so close to working, I had an issue while switching between cameras. There is no way that I could find to transfer the orbit rotation of one camera to another, so when switching to the FPS camera, the FPS camera snaps to the character's current direction. This means the character would have to fully rotate to the location before the camera is switched, and the problem is there is no way to check the character's rotation in comparison the the orbit, and the character rotates at a fixed rate that I can not change. This method does work, however, you need a .5 second delay to be able to aim down sights and fully rotate to wherever you want, and this causes issues with not being able to cancel aiming, and slows the flow of combat.

Method 3: Workaround with Player Direction

The best workaround I found is to set the Character Direction of the player to Camera Direction while holding a weapon, and to set the Character Direction back to Movement Direction while not holding a weapon. This allows for the FPS Camera Method to work, as the character will always be facing the orbit direction. The problem with this however, is you can't look at your character from a different angle while it is holding the weapon.

Does anybody know if there is something that I am missing to make this work?

Thanks,

-Zach

Unity version:
2019.4.0f1
Game Creator version:
1.1.9
Answered

 I guess that what you want to do is to zoom using a scope, right? In that case, use the FOV action. FOV stands for Field of View. The default value is set to 60. Increasing the value will appear as you zoom out, while decreasing it will zoom in into the center.

Thank you for the response Marti. This is what I am looking to do, however, my trouble lies with the character being able to run into the center of my screen while using the action camera, which obscures the scope. I could slow the character down a bit, however I would like to keep a fast pace to the game.

Thank you,

-Zach

In that case, you could change the camera to first person while aiming and then zoom in using the FOV action. That way, the character will never get in the way. 

That is true, however my problem was that when switching to first person, you face towards where the character is pointing, instead of your orbit rotation. This causes the player to face places they don't want to, and can only be solved by a delay, which makes the player wait and watch the character spin towards the destination they wanted to shoot in, which is not practical, but annoying. Is there a way to make the player instantly face towards the orbit rotation? I have tried simply turning them, however it takes a fixed amount of time I can't seem to edit.

Edit: Also, when switching to the first person camera, the camera returns to the horizon. Is there a way to fix this?

Thank you,

-Zach