So I’m making a game where you basically move side to side dodging obstacles. It is pretty simple, but what I don’t know how to do is make it so that you can’t move out of the camera’s view. Here’s my code, it is pretty simple, but I just need to know how to get bounds in there:
#pragma strict
function Update ()
{
if (Input.GetKey (KeyCode.A)) transform.Translate (Vector3(-6,0,0) * Time.deltaTime);
if (Input.GetKey (KeyCode.D)) transform.Translate (Vector3(6,0,0) * Time.deltaTime);
}
If you couldn’t tell, it is a javascript code. It only has the code for moving, not bounds, so if anybody knows how to do that, please tell me. Thanks.