How would you make an object move 1 in a direction slowly but as it was moving not let you move in a diferetn direction till it reaches the the position that is one in that direction.(Trying to make grid based moment)
I have this so far
if (Input.GetButton ("y") ||Input.GetAxis("upd") > 0){ //|| Input.GetAxis("stickup") < 0) {
GameObject.Find("MovePoint").transform.position.z += 1;
//moves object forward
}
else if ( Input.GetButton ("a") ||Input.GetAxis("upd") < 0){ //|| Input.GetAxis("stickup") > 0){
GameObject.Find("MovePoint").transform.position.z -= 1;
//move down
}
else if ( Input.GetButton ("b") ||Input.GetAxis("lrd") > 0 ){//|| Input.GetAxis("stickl") > 0){
//move right
GameObject.Find("MovePoint").transform.position.x += 1;
}
else if ( Input.GetButton ("x") ||Input.GetAxis("lrd") < 0 ){//|| Input.GetAxis("stickl") < 0){
GameObject.Find("MovePoint").transform.position.x -= 1;
//move left
}
}
transform.position = Vector3.Lerp (transform.position, GameObject.Find("MovePoint").transform.position,Time.deltaTime * smooth);
This does work but it sends you flying in a direction if the button is held down. I want you only to be abel to move again if you’ve got to your destination.