Download

physics pushing a pawn that uses navigation

Is there a way to physics push a pawn that is using the navigation system?

I started a new project from the top down template (sort of Diablo style click to move movement), which uses navigation to reach a position as opposed to impulses or anything physical. I’m trying to create regions which push on the player as they move, like standing in a wind tunnel or on a moving sidewalk.

I can’t seem to find the right combination of settings that would allow a pawn to be moved both by the navigation system and by a force or physics impulse. Whenever I turn on physics for the capsule on the pawn, they stop navigating entirely. Without physics on, I don’t think any sort of force or impulse will effect them.

Are you working in Blueprints only or in code?

If you are doing this in code I would suggest overriding UCharacterMovementComponent::CalcVelocity(). This function is what applies acceleration and pathfollowing to the velocity used each frame. Currenly when using path following, velocity and acceleration are completely overridden.

Basically you want to apply a constant acceleration each frame. So something like:



void UCharacterMovementComponent::CalcVelocity(float DeltaTime, float Friction, bool bFluid, float BrakingDeceleration)
{
	Super::CalcVelocity(DeltaTime, Friction, bFluid, BrakingDeceleration);
	Velocity += ExternalForce * DeltaTime;
}


where “ExternalForce” is the force you are adding.

If you are working in BP only, I can’t think of a good option at the moment, due to the internals of how path following is overriding velocity and acceleration. I was going to suggest the same approach as in code but there is not a convenient hook. I’ve started an internal discussion about possibly addressing this and structuring the code to allow input and/or external forces to be layered on the path following.

Yeah for now you’d have to get really creative in a pure Blueprint. Like spawn an invisible pawn. Have it follow the path. Your real pawn uses that location and adds external force. If you know a tiny bit of C++ though it would be way easier to add that FVector as a member var