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

Question Entity with two Physics Shapes registers twice when going through a trigger

Discussion in 'Physics for ECS' started by Marcusaralius76, Oct 27, 2021.

  1. Marcusaralius76

    Marcusaralius76

    Joined:
    Nov 13, 2018
    Posts:
    4
    I am building an RTS prototype, where units follow a non-physical Army Entity to get them from point A to point B.

    The army entity has a Physics Body, along with two physics shapes: a trigger that will change size based on the army's intel range to find other armies, and a collider that can be found by the trigger and collides with the terrain, so it can find terrain features. Both are spheres.

    PROBLEM: when one army passes into the detection sphere of another army, the trigger buffer registers the attached entity twice, which means the other army is counted twice when decision-making takes place.

    WHAT I'VE TRIED:
    Disabling the trigger on one of the armies: It worked, but now that army doesn't detect enemies.
    Playing with filters: No effect.

    Is there a feature I'm not aware of to prevent this, or an alternative to a physics shape so I can remove the trigger entirely?
     

    Attached Files:

  2. DevViktoria

    DevViktoria

    Joined:
    Apr 6, 2021
    Posts:
    94
    I am totally new to this, so maybe my idea is totally wrong. But have you tried to move the collider physics shape of the army to a child empty game object of the army? Like in the compound collider examples or in the manual? Because in this way the collider should still work, but the trigger may not fire two times.
     
  3. Marcusaralius76

    Marcusaralius76

    Joined:
    Nov 13, 2018
    Posts:
    4
    Thank you for the input! I just tried it twice. Once with the collider and once with the trigger in child entities. Unfortunately, I got the same result both times.