Camera Question... (88978)

Simple question, google gave me a lot of answers on the subject but none of the answers that I found worked for me or did what I needed it to do.

Just need a hint on how to stop camera rotation and just follow the character.

I am making an old school type Zelda clone…kind of. Right now I have the simple character controller script from the unity resources help page, and I have modified it some to meet my needs.

I admit it is really late…or early. I have been trying to solve this for the greater part of a day and I may have, in my exhaustion missed something super simple. Any help would be welcome. I am not looking for a script but maybe a link to the help page that would show something i could use would be awesome.

I am using C#. No Unity script or java or whatever please.

Thank you :3

1 Answer

1

Vector3 newPosition = playerObject.transform.position;
// Maintain the camera’s original z position
newPosition.z = this.gameObject.transform.position.z;
this.gameObject.transform.position = newPosition;

How you get an instance of the player object you’re following is up to you.

Put this code in some MonoBehaviour script and attach it to your camera.