Top Down Camera Rotation

Papazingo

New member
Hi,

I'm trying to add camera rotation, when moving the mouse on the X axis, to the top down view type when moving, without the character rotating . Most of the other views rotate the player when moving, however i would like to keep all the top down movement and view the same and just rotate the camera.

I understand i probably need to create a new view type but i'm struggling with this. Can you post a small bit of code as a starting point to just rotate the camera. Im sure i can work out the rest my self.

Thanks in Advance
 
I would start by trying with a sub-class of the included TopDown view type and applying your own further modifications to the rotation returned by Rotate(). Something like this would be a good place to start:
C#:
    public class TopDownSpinning : TopDown
    {
        public override Quaternion Rotate(float horizontalMovement, float verticalMovement, bool immediateUpdate)
        {           
            Quaternion rotation = base.Rotate(horizontalMovement, verticalMovement, immediateUpdate);
            return rotation * Quaternion.Euler(Vector3.forward * degrees);
        }
    }
You'd want to also block the TopDown base from continually attempting to re-align the camera's rotation with the player character, so you'd probably want to actually just re-write Rotate() with code based on TopDown.Rotate()
 
Sorry, i have a few more questions:

In the top down view type script, is the Move() function only for camera movement or rotation as well? and when you say re-write Rotate() you mean in the Top down script or actual camera controller?

Thanks
 
Move only handles the position of the camera and Rotate only handles its rotation.

For Rotate, take a look at TopDown.Rotate (line 149). It's a small function, just a few lines. It keeps the camera's rotation static, but you should be able to write a modified version of it within your custom ViewType script so that it allows for rotation around the upwards axis.
 
Top