Limit of a move for position
i used transform.position for change the position, but i dont wanna that the player move if have a object in desired position 3d game
void Update()
{
if (Input.GetKeyDown(KeyCode.UpArrow))
{
transform.position += new Vector3(-67, 0, 0);
}
if (Input.GetKeyDown(KeyCode.DownArrow))
{
transform.position += new Vector3(67, 0, 0);
}
if (Input.GetKeyDown(KeyCode.LeftArrow))
{
transform.position += new Vector3(0, 0, -56);
}
if (Input.GetKeyDown(KeyCode.RightArrow))
{
transform.position += new Vector3(0, 0, 56);
}
}
Comment
Answer by lgarczyn · Jan 21, 2020 at 10:20 PM
Sounds like you want collisions. The simplest way to do this is the CharacterController. The documentation has a very simple script to do exactly this.
Your answer
Follow this Question
Related Questions
stutter when going next a cube 1 Answer
Need help with high speed collisions, sanity dwindling 1 Answer
Unexisting blocks colliding and existing block not colliding 1 Answer
Move to mouse position, (if start pressing from the character) - HELP 0 Answers
Movement causing infinite loops in OnTriggerEnter and OnTriggerExit. 1 Answer