Search Unity

Walking through walls

Discussion in 'Physics' started by ItzChris92, Sep 16, 2018.

  1. ItzChris92


    Apr 26, 2017
    Hi, I've been playing around with cave generation, and using this:

    The problem i'm having is my character is able to move through walls. The walls themselves have a mesh collider, whilst my player has a kinematic RB, and a capsule collider (I've tried this capsule collider on both my player object, and a child of with the same results).

    I've searched high and low, but haven't been able to come up with a solution. I'm hoping someone can offer a bit of advice as there seem to be lots of cases where this issue has remained unsolved!

    EDIT: Also, just to clarify, I move my player using rb.MovePosition rather than transform.translate
  2. StickyHoneybuns


    Jan 16, 2018
    Review the Collider documentation found here:

    You may need to review mesh colliders as well.

    If you look at the matrix at the bottom of the colliders overview, you will see your problem.
    You have a Kinematic Rb Collider colliding with a mesh collider(non Rb I assume).
    This means no collision is being detected.
    Reveiw the collider matrix and decide what you need to do to fix it.
    You should be able to use non-kinematic Rb on your player but I don't know how your player is setup.

    Also, I did not look at the cave generator but it really is irrelevant and you just need to follow the collision matrix.
    Another thing, is usually good practice to avoid mesh colliders if possible.
    The reason being is because they are expensive and usually do odd things like you have found.

    Here is a recent post explaning the cost of mesh colliders