Hey folks, pretty straight forward one here. I have a player character object on the ground, and an angled camera in the air. The camera doesn’t need to rotate around or anything like that, all I’m wanting to do is have the camera offset from the player character position by a few units. I can’t for the life of me remember how to actually reference the player object position inside the cameras transform.Translate vector3.
Can anyone help me out with this derpy one
Edit:Basically on the camera, all I wanna do is
Transform.position = new Vector3(0,0,PlayerPosition-10)
But I can’t dig up the right syntax lol
You usually must have a target variable that references the target, and keep some predefined offset from it (camera script):
Transform target; // drag the target here (or find it at Start)
Vector3 offset = new Vector3(0, 2, -3); // define the offset
transform.position = target.position + offset;
// you can also force the camera to look at the target:
This is a very simple following camera script - a more elaborated one could follow the target with Vector3.Lerp in order to have a smoother movement, and possibly keep a constant angle from the target.
NOTE: You can find the target at Start with something like this:
target = GameObject.FindWithTag("Player").transform;