- Home /
Duplicate Question
Why does my physics2D script cause the player to randomly stop moving?
In the script, it checks player input for a constant key during fixedupdate, then checks if the players horizontal speed is greater than his maximum set speed. if it isnt, then force is added to move them in a direction.
Now, while playtesting, the player has a tendency to accellerate evenly to max speed, keep an even-ish pace for a while, then will suddenly stop moving, and the key will need to be released and pressed again to move again. (function used is Input.getKey(Keycode.A); i believe)
The original script had an else statement, which, if the velocity was GREATER than max speed, it became max speed, but i was hoping to implement a knockback feature in the future, and im worried this would restrict that.
TL;DR: How do you keep a steady movement on a rigidbody2D that doesn't skip out, or move into walls as translate would?
Post a question including your code. Be sure to use the code formatting button or the question will be rejected. Just BTW, you're better to simply use the physics built-in to Unity, which is incredibly easier.
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
[2D] Moving the player 1 tile at a time using rigidbody movement 0 Answers
How to make a Grid movement (tile per tile) 1 Answer
Cannot move elements in 2D scene. Help 3 Answers
How to push an object in 2D grid style 0 Answers