Fighting with rotations

wmpunk

New member
I am having quite a bit of trouble getting my abilities to work correctly when they involve rotations and positions with the character and camera.
The current ability I'm working on is "LookBack" and it makes the character look behind them when activated while running (like in Dying Light)
but its been quite a headache to get to work correctly without modifying source scripts. With a few modifications it would be easy but I would like to post it in the forums and work as is.

In order to get it to work I have to change the the movement and camera view to FreeLook when activated and rotate the camera to the desired angle while lerping the min and max yaw values of the FreeLook camera to match and lerp everything back when de-activating. A little messy but this worked out. Now problem is I also need to rotate the first person objects in the opposite direction to keep them facing the player direction.. this is where things go wrong.. The above method does not work because there appears to be no built in method for rotating FirstPersonObjects. I tried just lerping the min and max yaw values of the FirstPersonObjects component but do to the math controlling the component certain values (regardless if "Lock Yaw" is on) will flip the arms in wild directions even if the current yaw of the weapon is in the correct range. I next tried to just disable the component all together when the ability is activeted and just rotate the transform, but certain abilities or events re-activate it throwing everything off.

I feel like I am trying to jump threw way to many loops to get this to work. I think that every component that rotates or alters positions should consistently have a rotation offset along with position offset. If this where the current case all I would have to do is lerp the rotation offset of the camera and the FirstPersonObjects offset and my code would be cut down by 2/3rd and be way simpler.

Any ideas on how to achieve this currently in a cleaner way?
 
It has been awhile since I played Dying Light but you'd want the First Person Objects to stay in the same position relative to the character, correct? In that case wouldn't you be able to use a state to lock the pitch/yaw of the objects so it always faces in the same direction regardless of the camera rotation? This is what we do with the interact ability in first person mode.
 
Ah thank you! That set me on the correct path. Now I have completed it and posted it in the scripts forum.
 
Top