Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Movement - Help

Discussion in 'Documentation' started by Ph_Mari3, Oct 14, 2018.

  1. Ph_Mari3

    Ph_Mari3

    Joined:
    Oct 14, 2018
    Posts:
    4
    Hy. I made a snake game, but I have an issue. For example, while moving right if I press left button my snake dies (because of colisions). How could I disable, while moving one direction, the input for the oposite direction? I tried several algorithms but none worked...
     
  2. Snake games usually utilize relative steering, which means
    - when the snake is moving to the right, pushing the left button, it will turn and move up
    - when the snake is moving to the left, pushing the left button it will turn and move down
    [...]

    In this case you just do not use the "down button", because it points towards the snake body itself all the time. Otherwise you turn your snake 90 degree to the proper direction.