Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Player and TileCollider not colliding

Discussion in '2D' started by TallLalasoda, May 19, 2019.

  1. TallLalasoda

    TallLalasoda

    Joined:
    Mar 5, 2019
    Posts:
    5
    Hi, can someone help me, I've got a bug I cant seem to fix. My Player character can't seem to collide with the tiles. Player has CircleCollider2D, RigidBody 2D (type Kinematic), and I move the player by editing its rigidbody component `rigidbody.velocity = new Vector2(horizontal * runSpeed, vertical * runSpeed);`. Tilemap has TileMapCollider2D (used by composite collider), Rigidbody 2D (static type) and CompositeCollider2D. OnCollisionEnter etc doesn't get called when they collide too, I believe it's something wrong with the player.

    My Player:


    The tileMap:
     
  2. blastedw

    blastedw

    Joined:
    Apr 29, 2019
    Posts:
    13
    Did you configure your collision Matrix under Project Settings -> Physics 2D?
     
  3. TallLalasoda

    TallLalasoda

    Joined:
    Mar 5, 2019
    Posts:
    5
    Hello, thanks for replying, nope I did not do that, am I supposed to do that?
     
  4. blastedw

    blastedw

    Joined:
    Apr 29, 2019
    Posts:
    13
    It's best practice to use different collision layers instead of Default. The collision layer is located at the top-Right Corner of the inspector (not the sorting layer)
     
    TallLalasoda likes this.
  5. TallLalasoda

    TallLalasoda

    Joined:
    Mar 5, 2019
    Posts:
    5
    Hey, thanks for the help! I actually managed to solve it by re-doing it in another Unity project lol, it seems that something went wrong after I imported some stuff into my previous project, so I ported everything into a new one.