Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Movement - Help

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

  1. Ph_Mari3


    Oct 14, 2018
    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. LurkingNinjaDev


    Jan 20, 2015
    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.