- Home /
Question by
Joystick_MoJo · Jul 05, 2017 at 07:59 AM ·
cameratransformprogrammingcamera-movement
camera follow obect on pan to z axis
i try to achieve camera similiar to an android game called geometry dash, but i hit a roadblock. i cant figure out how to pan the camera without updating target z postion constantly, please help Code
public GameObject player;
Vector3 camPos;
void Update ()
{
camPos = player.transform.position.z - ????;
gameObject.transform.LookAt (player.transform);
gameObject.transform.position = new Vector3 (0,0,player.transform.position.z - ????)
}
i cant figure it out
Comment
You're going to need to be somewhat more specific on what exactly you want. It's very hard to tell what outcome you are trying to receive from your description and the code.
Yes, it sounds to me that updating the position constantly is exactly what you need to have the camera pan (something has to change each frame, right? Unless the player is motionless). Not sure what the problem you're describing is, sorry.