- Home /
How to change player direction with one button?,How do I make one button change direction of player?
I have a unity project in school but have 0 knowledge of C#. It's due very soon and I'm just shooting my shot here, hoping for something.
I would like to make a snake/tron/endless runner vibe game.
Player will always continue moving in a straight line until a key is toggled.
Space key when pressed, changes horizontal direction. X key when pressed, changes vertical direction.
Player can only move along vertical or horizontal axis at any given time.
Ideally, with these controls, players can trace the shape of a square/ rectangular box.
I've viewed and tried possibly every question/forum on unity and none of them work for me. One of them seemed to work okay when horizontal component was added, but come vertical component, forces added up and player moved in a diagonal direction off the bat.
Please help....
p.s. one of the solutions had a goingRight = !goingRight aspect but pressing the Space key did not toggle the player's change in direction. Clicking the checkbox titled goingRight did. How do i solve this issue as well?