Hi all,
So I’m using Add force (+ Add to current) to move an object around in 2D space for a physics flying game.
The actor has force added in the direction the analog stick is aiming.
What is the best way to slow the sphere to a stop while a button is held.
(I’m using Axis input on a button for it to read as held (Axis value 1 = held), it ticks at the set FPS)
I’d like to have it gradually slow down over time using my predefined move speed to a stop.
e.g.
Slowing down at the Move speed variable and then gradually slowing to a stop.
Any ideas? Thanks!
Just a little more detail, the timeline node will allow you to manually set up how the speed of your object is interpolated, you can increase or reduce the speed of your object over the amount of time you set, all using curves. It’s kind of hard to get a hang of at first but in no time you will be good to go
That makes it a little more complex, if you’ve used timelines then don’t bother with the tutorial, but either way see where the timeline gets you, while you wait for a better solution.
I don’t know if this will work the way I need it too, I need it to occur every tick.
(I want it to slow down when the button is held)
If I do it on a timeline surely it will just play for some arbitrary time till it stops moving no?
(at work haven’t read the tutorial fully yet but I have tried timelines in the past for other things)
Thanks thats my current temp work around, I’ve got a few other methods but none of them work perfectly I’ll throw them up here when I get home for others (Hopefully to build on)
Every tick while the button is held, get your sphere’s velocity, multiply it by -1 and some “Braking Strength” number, and Add Force on the sphere with that vector. To limit the max braking force, pass it through a Clamp Vector Size node before plugging it into Add Force.
This method won’t mess up any physics interactions with your ball while it is braking, unlike changing its damping or artificially setting it’s velocity with a timeline. Using a multiple of the ball’s current velocity also ensures that the brake won’t do anything when the ball is stopped, or overshoot (unless you make the braking strength multiplier ridiculously high.)
Tried doing this before and it wasnt working the way I wanted it too because I was missing the clamp, it’s working now thanks!