2D Movement System (Stop Movement on Collision)
I'm trying to create a movement system for my maze game.
TLDR: Looking for a 2d movement system that infinitely moves the player in the chosen direction, and ceases movement on collision.
The player controls a square that moves infinitely up, down, left, or right when one of the arrow keys is pressed once, and only stops moving when the player's 2d collider "collides" with another 2d collider (aka the maze walls). This then resets, allowing the player to make another move.
I'm very much a newbie to coding, and would much prefer working on puzzle designs and art (haha), so any help you can provide would be greatly appreciated.
Answer by gustavo440 · Apr 19, 2021 at 06:04 PM
For this case you could go for the MonoBehaviour method OnCollisionEnter2D in order to detect the square collision with the wall and change the player speed to 0 when that happens.
Your answer
Follow this Question
Related Questions
2D Platformer, Icy material? 0 Answers
How to make a 2d platformer with a rolling ball as a player? 1 Answer
Switching lanes 1 Answer