hi all, I’m building a game which requires the camera to stick to my main object in the X axis. It’s a bike based game, so the object will be riding off jumps, etc, but I don’t want the camera to move up as the object does, only move along the X axis. Using C#, my code is as follows:
public Vector3 cameraFollowOffset = new Vector3(0,5,-5);
public Camera followCamera;
void Start(){
if (followCamera == null)
followCamera = Camera.mainCamera;
}
void Update(){
followCamera.transform.position = transform.position + cameraFollowOffset;
}
}
Many thanks