Search Unity

2d Tilemap collider not working.

Discussion in '2D' started by LordOfKspModding, Sep 14, 2018.

  1. LordOfKspModding

    LordOfKspModding

    Joined:
    Dec 8, 2016
    Posts:
    8


    The cube is supposed to hit the tilemap, but instead ghosts through. The cube has rigidbody 2d attached. Why? How do I fix this?
     
  2. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    833
    Do your tiles have a tag? If so, use a raycast from your player to determine your distance from the tiles. Then set a check to where IF you get (x) distance disable your movement in that direction. I had an issue like this with walls that I animated with the Unity animation tool. After animating, the walls became hollow to my player. So I created a TAG "Walls" and set forth a raycast. This did resolve the issue.
     
  3. chatrat12

    chatrat12

    Joined:
    Jan 21, 2015
    Posts:
    122
    What you have should work. Make sure the layers that you objects on are allowed to collided with each other. You can check under Edit->Project Settings->Physics 2D. Also make sure you that your box is using a box collider 2D and not a regular old box collider (I've done that before)

    Are you letting the cube fall via physics, or manually controlling it. If you are manually controlling it, what method are you using to add forces to the cube and what is your body type set to?
     
  4. LordOfKspModding

    LordOfKspModding

    Joined:
    Dec 8, 2016
    Posts:
    8
    Thanks! the collison layers fixed it!
     
    chatrat12 likes this.