In my project, I want the player to completely stop any previous movement while respawning.
Which wouldn’t have been a problem if it was only the result of player’s input as I’m pretty sure that’s what velocity does - but player can also die by knockback from another object (for example spinning platforms).
Is there any way to remove any knockback, momentum, etc… completely removing any sort of movement from the player?
Maybe get the player controller and disable input once the player dies to prevent the user from adding velocity during this time?
Another solution would be to pause the movement in the movement component.
And a rather clanky solution for momentum would something like :
For disabling the controller, while it does solve some situations, my main problem is knockback by other objects. for example the player getting knocked by a moving platform into something that kills it and then respawn with the same knockback impacting it… (For example, imagine a player walking down the street, a car hitting him, the player spawns at his house and them immediately proceed to fly into the nearest wall by the impact of the car that just ran it)
As for the 2nd solution, I did try to do:
GetCharacterMovement()->Velocity = FVector(0.0f,0.0f,0.0f);
but sadly it doesn’t change anything (maybe getting the velocity only returns a copy and I’m not aware).
I tried to use your function both without GetCharacterMovement() and with it but for some reason it doesn’t seem to exist… Should I include anything else for it in the header? Or is it different in ue5? Tried to use it inside my character class.
Regardless, I thank you a lot for both suggestions and for trying to help
Hi! So sorry for the late reply!
The GetCharacterMovement() function is defined in the ACharacter class, so if you write your code in the YourCharacter.cpp, then you could use:
The StopMovementImmediately() function stops the current movement instantly and zeroes out the velocity.
If that wouldn’t work for you, there are other functions defined in the movement component that might else work, such as: