Starting from the Roll-A-Ball demo project, I want to extend the camera script to follow the player, but also keeping track of the direction of movement.
Ex: If the ball starts moving to the side, I need the camera to rotate around the player’s axis to position behind him, and then start following him.
The original camera script from the example project:
public GameObject player;
private Vector3 offset;
void Start ()
{
offset = transform.position - player.transform.position;
}
void LateUpdate ()
{
transform.position = player.transform.position + offset;
}