Im having some problems making the camera turn with the ball. Camera dont Turn - YouTube in the YouTube link you can see the camera is following the ball but only show it from the same angle. I would like the camera to turn with the ball, so the backside of the ball is seen and it’s possible for the player to see the road ahead.
public GameObject player;
private Vector3 _offset;
void Start()
{
_offset = new Vector3 (0, y, z); //just put the values that you want instead of y and z
}
void FixedUpdate()
{
Vector3 flatSpeed = player.rigidbody.velocity;
flatSpeed.y = 0;
//stores the flat velocity of your player so it can put the camera always behind it
Quaternion wantedRotation;
if (flatSpeed != Vector3.zero)
{
float targetAngle = Quaternion.LookRotation(flatSpeed).eulerAngles.y;
wantedRotation = Quaternion.Euler(0, targetAngle, 0);
}
tranform.position = player.transform.position + (wantedRotation * _offset);
transform.LookAt(player.transform);
}
Try parenting the main camera to the ball. It seems simple, and it is, but works surprisingly well.
If that fails, follow this tutorial. It’s in the middle of a series on RPG character controllers. The camera script works quite well, and you should have a very aesthetically pleasing result.