Hi
I am new to Unity and programming. I am making a game(in 3D) where there is a player and a camera both moves at a same speed in x axis. and user has only control to move the player up and down to avoid the obstacles which are coming towards him (So player is moving from left to right and obstacles from right to left).
But my problem is I am not able to restrict the player going out of screen. i.e if I keep pressing up arrow player goes out of screen same for down arrow. There are some answers for this in this forum but I am not able to make it work. Here is my code for camera and player
For Camera Controll
function Update () {
transform.position.x += ManControll.moveSpeed * Time.deltaTime;
}
For player control
pragma strict
static var moveSpeed:float = 5;
var updownSpeed:float = 100;
function Update () {
transform.position.x += moveSpeed * Time.deltaTime;
transform.position.y += updownSpeed * Input.GetAxis(“Vertical”) * Time.deltaTime;
}