My current task is to make the camera follow the moving cube in a stable way where the camera won't get locked in the center of the object so it won't get dizzy once the cube starts to collide or fall down.
I have done the parenting right, I have named the cube as the player and then selected it as the Transform reference in the new component that I have created for the camera to follow.
But it just says:
UnassignedReferenceException : The variable player of FollowPlayer has not being assigned.
and I am unable to get the right results. What should I do ?
Here is the C# script that I wrote:
using UnityEngine;
public class FollowPlayer : MonoBehaviour {
public Transform player;
public Vector3 offset;
void Update() {
transform.position = player.position + offset;
}
}
My scene setup looks like this:
So I have un-parented the main camera from the player and it works perfectly fine but I still get the error, Have any ideas why?