Smooth Follow With Rotation

I am currently using the smooth follow script for my game but I am wanting to add rotation around the object controlled by pressing the A and D keys.

I have tried using rotate around but it conflicts with the smooth follow script making the rotation jerk lots. Any ideas?

Hello, there is a very simple solution for your problem.

I guess you dont want to rotate the object, only the camera around the object right?

There for create an empty gameObject, I called it Rotator, and make it a child of your Object you want to rotate around. Now put a script (I use js.) on the Rotator and write following in it:

private var speed : float = 5;

function Update () 
{
    rotation = Input.GetAxis("Horizontal") * speed;
    transform.Rotate(0,rotation,0);
}

Now go to the camera and declerate as target of the “SmoothFollow” script the Rotator instead of your Object. Now you should be able to rotate the camera around the object.

If i have missunderstand you and you also want to rotate the object with it, skip the Rotator and put the script directly on your object.

Hope I could help, good luck with your project!

This can be done with the MouseOrbit script that comes with the standard assets.

Simply open the script and change lines 27 and 28 from:

`
        x += Input.GetAxis("Mouse X") * xSpeed * 0.02;
`
`
        y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02;
`

to

`
        x += Input.GetAxis("Horizontal") * xSpeed * 0.02;
`
`
        y -= Input.GetAxis("Vertical") * ySpeed * 0.02;
`