rotate around ball

I’m going to rephrase my question because this isn’t working.
I’m looking for a script for rotating around your character (the ball), when you press the input keys (up,down,left,right)

If your character moves forward (up), the camera goes behind you (does nothing).
If character turns left, the camera rotates 90 degrees right to follow you and stay behind you.
if you press “down” the camera will rotate 180 degrees and follow you.

the only difference is you are not moving the ball, you are tilting the game board to make the ball roll around a maze; and the camera follows the ball in 3rd person.

This is used in every 3rd person (over the shoulder) game; this can’t be hard.

Move the camera to a position relative to (ballGameObject.transform.forward * -1f) and have the camera look at the ball. ballGameObject.transform.forward * -10f would put the camera ten units behind the ball, transform.up would work similarly.

Create an empty object, and give it:

var ball : GameObject;
function LateUpdate() { 
 transform.position = ball.transform.position; 
 transform.LookAt( transform.position + *insert ball velocity here* );
}

Make your camera a child of that object. The object will face the direction the ball is moving (you may need to make a special case for zero movement), and the camera should spin around with it.

i have a solution. create another new gameoject and make it child of the character at centre of character(0,0,0). then make camera new gameobject’s child and keep it at a desirable dist. which will be the radius at which the camera will rotate.camera should point at character in scene. now you can rotate the new gameobject using transform.rotate