Hey guys!
I’ve been wondering if it’s possible to get the velocity of an object for example when a force is added to an object (for example an actor based blueprint’s component) I’d like to be able to get its velocity to check when it has reached near zero so I can set its velocity to zero or just see if it already is zero (both would work in my purpose), I’d then enable something for the player to do next but I do need this checking point for the velocity.
Thanks!
Hey Elias,
Actors have a GetVelocity function that returns the current velocity. To get its speed, take the length of the velocity vector.
There is no SetVelocity though. If you want to make it stop and you’re moving it programmatically, maybe just don’t tell it to move if its speed is below a given threshold.
If it’s a physics object it’s best to let it come to a stop on its own. You might want to play with its Linear Damping property to get the best results. To force it to stop moving you could always disable simulating physics on it until it should move again.
Hi !
Thanks for taking the time to answer. Well that was pretty easy, the best part is I already knew about this blueprint I just had some problems with it (didn’t know how to use it in this case). Thanks!
In a Character blueprint, I think you would be able to set the velocity to zero by using the function “Launch Character” with zeroing all of of its parameters and with “XYOveride” box checked.