public class CameraController : MonoBehaviour
{
public GameObject player; // add your player object in the tool
private Vector3 offset;
void Start ()
{
offset = transform.position - player.transform.position;
// offset is used for storing the difference between your scene camera position and your player position
}
void LateUpdate ()
{
transform.position = player.transform.position + offset;
}
}
//here we are changing the position of camera according to the player movement. It means, wherever your player move your camera will follow it.
0 Comment(s)