StopMovementImmediately called on pawn possession?

I have a pawn with a custom movement component and a custom player controller that manages the selection of various pawns.

I noticed that when selecting a pawn, any movement it is engaged in instantly stops. I did some debugging with GDB and figured out that the culprit is APawn::Restart(), which calls StopMovementImmediately like so:

void APawn::Restart()
        if (GetMovementComponent())

I don’t want this behavior though! If the pawn is moving when the PC possess it, I want it to keep on moving. I was able to “fix” it by overriding the Restart() method on my custom pawn class and not passing it on to the base pawn, thus eating the event. But this seems like a hacky and possibly dangerous thing to do: for all I know, APawn::Restart is important somehow…

Is there a better way to address this than my blunt hammer above? And what is the point of the behavior, anyway?

Thanks for any insights!

Hey dude, I think you had the same issue as me but I encountered it when using blueprints.

My fix was to set a variable that contains the velocity of the pawn I want to posses then possess the pawn and apply the stored velocity to the pawn immediately after and that works for me.

Hi Danny,

Yeah, it seems like the more sensible default would be for the pawn to continue its movement, and if you want it to stop you call a halt-movement method explicitly. At least there are some easy workarounds though…