Search Unity

Looking for advice on 2D attack collision system

Discussion in 'Scripting' started by Thimble2600, Oct 18, 2017.

  1. Thimble2600

    Thimble2600

    Joined:
    Nov 27, 2015
    Posts:
    165


    Hi there, I'm looking for advice on different ways to handle 2D attack-based collision events.

    Currently all entities in my game have a particle system that emits a particle when attacking that triggers an `OnParticleCollision` event on entities hit. This seems to be working well, however I'm concerned that this isn't a practical method. If you were making a game like the one shown in the image above how would you handle such an event?

    Another method I've considered is using raycasts since they use very few resources.
     
  2. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    630
    Hi, Welcome.

    The best way to handle this kind of collision system is to use Raycasting as yourself suggested.
    But you can use colliders for projectiles such as bullets and arrows.
    But the best collision system for 2d swords is Raycast if your animation is fast enough.

    Thanks.
     
  3. AdamAlexander

    AdamAlexander

    Joined:
    Jul 24, 2015
    Posts:
    73
    Hello, yes I agree that using a particle system for these collisions is definitely not a practical method. Raycasting and trigger colliders are both much better suited to what your doing.