Character gets stuck when walking on ledges

Hello

Im working on a 2d platformer and lately i noticed that if i try to walk off a ledge, my character tends to get stuck on said ledge, landing on the same platform seems to fix this (as in if i do a small jump, land on the platform and then try moving off the ledge it works )

Here is a video that showcases the issue

Video Link

I alredy have Can Walk Off Ledges as true on my character movement component, as well enabled the Flat Floor Box Checks but nothing seems to really help with this

From the video it is hard to tell. There is no blueprint visible.
But i think it has something to do with your characters animation blueprint.

As soon as you character reaches the corner of the platform it blends the move forward animation out into the “falling animation” and only starts falling after the falling animation. This is just a visual perception. While this blend happens, the character seems to be stuck.

Anyway - the movement is unnatural. I would expect to see a parabolic flight path of your character dropping of the edge. But it goes full stop and then straight down.

Ho do you handle “falling down”? Something is odd here.

Hey, Thanks for the quick reply!. sorry. just to make it clearer my issue is happening on the 2nd play in editor try, If i start moving to the right, as soon the game begins and reach the edge of the platform then the character becomes stuck for a few seconds before finally dropping down ( it happens at 0:03, Im holding the movement key to the right but the character is still on the platform and not falling down even though theres no floor below him. If i had let go of the direction key in that moment he would had dropped down right away )

As for falling down, The only modification i have done to it is that, if the player movement mode is Falling and there is no input from the controller ( MoveRight is 0 ) then the player Velocity Y is set to 0 (Since i dont want any sort of momentum or acceleration while moving in the air and the player should remain still when there is no input applied )

I ended up fixing the issue. by using the FindFloor function whatever the player is on the walking state and setting his movement mode to falling when it returns false ( which essentially is the case i had, the character was still on the walking movement mode but wasnt getting his physics movement mode set to falling for some reason )

I had a lot of fun with this the last two days. I’m on UE 4.27.2, but I imagine the CharacterMovementComponent didn’t really change much. The code responsible for the behavior you’re seeing is in UCharacterMovementComponent::StartFalling. It looks like this:

		// This is to catch cases where the first frame of PIE is executed, and the
		// level is not yet visible. In those cases, the player will fall out of the
		// world... So, don't set MOVE_Falling straight away.
		if ( !GIsEditor || (GetWorld()->HasBegunPlay() && (GetWorld()->GetTimeSeconds() >= 1.f)) )
		{
			SetMovementMode(MOVE_Falling); //default behavior if script didn't change physics
		}

So they hardcoded a 1 second long threshold to not let the character fall through the level when you play in the editor. You would not have seen the character glitch on ledges in a shipping build.

…

1 Like