Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Projectile collision with Tile

Discussion in '2D Experimental Preview' started by Soulice, Oct 11, 2017.

  1. Soulice

    Soulice

    Joined:
    Aug 18, 2014
    Posts:
    69
    I have the tilemap working, have 4 tiles some set with no collider type and others with Sprite collider. Things work well, player can not pass sprite collider tiles, nor can projectiles. I am missing something, though. I am not sure how to check the collision of the projectile with the tile so I can destroy the projectile on impact. How would that be done?
     
  2. Soulice

    Soulice

    Joined:
    Aug 18, 2014
    Posts:
    69
    Think I found something. On TileMap, in the Collider, set IsTrigger true, then check for this trigger enter on the projectile...seems to work and projectile stops on tiles with colliders and flies through those with no collider.

    I assume this is the right way to do this?

    EDIT: this helped projectiles, but apparently changes the collider that was working for my player. Now he walks through walls.
     
    Last edited: Oct 13, 2017
  3. WilkerLucio

    WilkerLucio

    Joined:
    May 2, 2017
    Posts:
    18
    Alternativelly you can put a OnCollisionEnter2D() on your bullet and put the destroy or the disabling bullet code in there.
    I think you could also make the bullet collider trigger and still use the same code you have now (I'm not sure this will work though).
     
  4. Soulice

    Soulice

    Joined:
    Aug 18, 2014
    Posts:
    69
    Thanks, will give it a whirl.