(Solved) Character Floats After Hitting Head on Object

Basically the character is “hanging” after you jump and he hits his head on a platform only while move left or right. If you are standing still he hits his head and returns normally to the ground (mario style). If you are moving to the left or right he will float for a short while until gravity picks him back up again. If you leave from under the platform you hit he falls normally right away.

It’s a problem that I’ve had since the beginning and I’ll spend a few hours trying to fix it, leave defeated only to come back and spend a few more hours on it another day. The cycle repeats. Any help would be immensely appreciated! :slight_smile:


// Move the controller, and set collidedDown true or false depending on whether we're standing on something
		//Detect character controller collision		
		collidedDown=(flags & CollisionFlags.CollidedBelow)!=0;
		collidedUp=(flags & CollisionFlags.CollidedAbove)!=0;
		collidedSides=(flags & CollisionFlags.CollidedSides)!=0;
		// Apply gravity
	  	moveDirection.y -= gravity * Time.deltaTime;

Your problem is, that your setting move direction to 0. When your character hit’s something, it goes “into” it, so for a short amount of time his velocity will always be 0
how about setting it to 0 only if it’s above 0?

if (collidedup && moveDirection > 0) {
    moveDirection = 0;