Hello, I’m pretty new to unity and I don’t know why this is happening but I’ve written this code that is meant to lock the camera’s position to the player, but it just doesn’t work.

As you can see in this gif, the cube just falls and the camera does not move to the cube’s current position.
I could simply just drag and drop the camera into the cube, but the problems with that is when the cube rotates when either jumping on an edge, which I want but the camera rotates as well.
Here’s the code, by the way the Main transform is set to the player’s transform.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraScript : MonoBehaviour
{
public Transform Main;
private Camera camera;
void Start()
{
camera = GetComponent<Camera>();
}
void LastUpdate()
{
camera.transform.position = new Vector3(Main.position.x, Main.position.y, Main.position.z);
}
}
,