Hello!
This week I started by giving the camera some simple movement behavior. Basically I make it follow the player’s position (with a certain offset) and rotation though somewhat slowly so that it’s movement becomes more smooth rather than sudden and jerky. I am mainly making use of ‘Slerp’ and ‘SmoothDamp’ for the camera’s movement.
I’ve also managed to get the direction correction for the movement to work as intended. What I had missed was that I needed to make use of conversion between local space and world space in the engine.
Here is a copy of the sample code if it’s hard to see:
- // C# / UnityScript
- var yVel = rigidbody.velocity.y;
- var localV = transform.InverseTransformDirection( rigidbody.velocity );
- localV.x = 0.0f;
- localV.y = 0.0f;
- var worldV = transform.TransformDirection( localV );
- worldV.y = yVel;
- rigidbody.velocity = worldV;
Taken from:
http://answers.unity3d.com/questions/412078/keeping-forward-velocity-always-in-the-same-direct.html
Lastly I encountered a problem with the rotation boxes (triggers that will rotate the player automatically, but only in the x-axis and z-axis) when they are used in the actual level we were going to use for the Beta.
For some reason they stop working properly when their local z-axis is aligned with the world y-axis. I thought I could fix this by making use of local rotation values just like I did with the movement but it ended up making things worse as all rotation boxes regardless of placement stopped working properly.
Worst case scenario we will have to move on without any automatic rotation as there isn’t much time left.
Cheers!