Smooth Wall Movement in Phys_Flying?

Hitting a wall in Phys_Walking mode results in the player attempting to slide around it. When in Phys_Flying mode the player will no longer attempt to slide around a wall or obstruction. Instead the player just comes to a complete halt. How do I allow the player to smoothly move around obstacles while in phys_flying mode?

I attempted to apply a slide with the function HandleImpact found in MovementComponent. Although it seems that HandleImpact does not get called on every hit wall.

Hi Skylar, I fixed this a while back but it didn’t make it to the Rocket release yet. There was a bug where if the StepUp in PhysFlying failed, we didn’t try to slide along the surface instead.

I suppose you could possibly fix this in the interim by overriding StepUp yourself to just call the Super method, and if it failed and you are flying, do the SlideAlongSurface call yourself. Just remember that the FHitResult could be modified by the StepUp call (this is actually gone now, but was still the case in your release).

So something like this:

void UMyMovement::StepUp(...)
{
	FHitResult HitPreStepUp(Hit);
	if (!Super::StepUp(...))
	{
		if (IsFlying())
		{
			Hit = HitPreStepUp;
			HandleImpact(Delta);
			SlideAlongSurface(Delta, 1.f - Hit.Time, Hit.Normal, Hit, true);
		}
		return false;
	}
	return true;
}

As for HandleImpact not being called, that looks like a bug in PhysFlying as well, so thanks for pointing that out. We don’t always call it for every hit, really only hit where we consider ourselves blocked and where we are going to slide around something, but this should happen in this case.

Zak,

Your fix works perfect! Thank you for the excellent answer!