- Home /
Movement with infinite directions acceleration
Hey, im experimenting with top down movement where you move in input.getaxisraws direction. I made a prototype that works fine, but i've been trying to add acceleration to this, which has caused me cuite a lot of problems. I know i could use input.getaxis instead of raw, but that's not gonna work with a keyboard, and it's not really giving me the controll i need.
So, i tried by just having a speed value increase while moving, but that of course makes it retain its speed when changing direction. So i experimented with deaccelerating to 0 then accelerating to speed again when changing direction but i couldn't find a way to write that while retaining the infinite directions, well not infinite but its not just 4 or 8.
So yeah my question is, do you know of a way to have the player move in input.getaxisraws direction, while also having acceleration, deacceleration, and not retaining speed when changing in the opposite direction.
I hope i clarified my questions enough to make it understandable, sorry in advance if im its too messy, thanks if you can help.
Answer by Z-ion · Jul 10, 2019 at 02:42 PM
If you are using Rigidbody then you can use Rigidbody.AddForce(direction*velocity, ForceMode.Acceleration) or ForceMode.Force which one works fine for you.
I hope it help you out.
Your answer
Follow this Question
Related Questions
Making a bubble level (not a game but work tool) 1 Answer
Spaceship movement with acceleration and deceleration on Unity 0 Answers
Doing something wrong with lerp? 1 Answer
Acceleration problems (don't know how to make it stop moving) 0 Answers
Trouble with diagonal acceleration in Quake style movement 0 Answers