Search Unity

2D characters falling through Mesh Collider

Discussion in 'Physics' started by DanielRiches, Dec 10, 2019.

  1. DanielRiches

    DanielRiches

    Joined:
    Nov 23, 2019
    Posts:
    166
    So I made a 3D platform after 3 days of bashing my head against Blender.

    I imported it, added a mesh collider and a Rigidbody, but my 2D characters simply fall through it every time, no matter what option I try checking or un-checking on the mesh collider (Kinematic, Convex, anything) they just wont land on the platform.

    characters are using 2D Box Colliders, the platform is Mesh Collider on a 3D model.

    I have tried all other types of collider with the same result...

    Any idea why this isnt working?

    Screenshots attached



     
  2. tjmaul

    tjmaul

    Joined:
    Aug 29, 2018
    Posts:
    467
    I would guess that 2D and 3D colliders live in different worlds. Have you tried adding a 3D collider to your character?

    You can also just create a 2D box collider close to the ground to represent the surface of your 3d model. Since it’s 2D anyways, your character should not be able to move into and out of the scene.
     
    Last edited: Dec 10, 2019
  3. DanielRiches

    DanielRiches

    Joined:
    Nov 23, 2019
    Posts:
    166
    My character uses a script to edit it's colliders, using 2 different 2D box colliders as a stand and duck so he can squeeze into tight spaces, I'll try and set this up using 3D ones but I was hoping to keep the current system.

    Thanks for the suggestion.
     
  4. tjmaul

    tjmaul

    Joined:
    Aug 29, 2018
    Posts:
    467
    you can keep your system of 2D box colliders but then you have to remove the 3D mesh collider and replace it with a 2D box collider.
     
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,459
    2D (Box2D) and 3D (PhysX) physics are separate systems, they don't interact and are not one super physics system. You need to choose one or the other.
     
  6. DanielRiches

    DanielRiches

    Joined:
    Nov 23, 2019
    Posts:
    166
    Yeah adding a 2D box works, but not mesh, thats unfortunate!

    Thing is, my character is 2D but the environment will be 3D in places, how do box colliders work if say a platform isnt completely "flat"? Although im sure I can try and counter it by using perspective so the character isnt stood directly on the floor but looks like they are from the players perspective.