Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a third person controller which uses physX to interact with the other objects (using the Rigidbody component) and Mecanim to animate the character.

All the animations used are baked to Y, and the movement on this axis is controlled by the gravity applied by the rigidbody component.

The configuration of the falling animation:

Falling animation configuration

And the character components configuration:

Character configuration

Since the falling animation doesn't have root motion on XZ, I move the character on XZ by code. Like this:

    // On the Ground
    if (IsGrounded())

        // Stores the velocity
        velocityPreFalling = rigidbody.velocity;
    // Mid-Air
        // Continue the pre falling velocity
        rigidbody.velocity = new Vector3(velocityPreFalling.x, rigidbody.velocity.y, velocityPreFalling.z);

The problem is that when the chracter starts falling and hit against a wall in mid air, it gets stuck to the wall. Here are some pics which explains the problems:

Problem - Expected

Problem - Reality

Hope someone can help me. Thanks and sory for my bad english!

PD.: I was asked for the IsGrounded() function, so I'm adding it:

    void OnCollisionEnter(Collision collision)
        if (!grounded)

    void OnCollisionStay(Collision collision)

    void OnCollisionExit()
        grounded = false;

    public bool IsGrounded()
        return grounded;

    private void TrackGrounded(Collision collision)
        var maxHeight = capCollider.bounds.min.y + capCollider.radius * .9f;
        foreach (var contact in collision.contacts)
            if (contact.point.y < maxHeight && Vector3.Angle(contact.normal, Vector3.up) < maxSlopeAngle)
                grounded = true;

I'll also add a LINK to download the project if someone wants it.

share|improve this question
up vote 1 down vote accepted

The problem was caused by the friction configuration on the character's physic material. Changing it as the image shows fixed the problem:

enter image description here

It seems that over .001 of dynamic friction and .01 of static are enough to start slowing the fall of the character when hitting a wall.

share|improve this answer

Most of the mecanim setup stuff is irrelevant; this question mostly rests on what IsGrounded() is doing. Whatever is happening in there to detect the ground is not working correctly, and it considers hitting the wall to be "on the ground".

share|improve this answer
The function IsGrounded() is used by me to know if I should allow the player to control the character or not, and to apply an XZ velocity to the body in order to continue the pre-fall movement. I will add the code of this function to the question. – Celtc Aug 13 '14 at 23:01
If the problem is that it's detecting that the character is on the ground, then it's the rigidbody component which is bugged, because it's this component who applies the gravity. And I cannot tell him, or at least I don't tell him, when the character is on the floor. I thought that this component was applying a constant force towards the ground, don't matter if it is grounded or not. – Celtc Aug 13 '14 at 23:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.