Search Unity

ITriggerEventsJob does not work with RequireComponentTag

Discussion in 'Entity Component System' started by Quit, Apr 12, 2020.

  1. Quit

    Quit

    Joined:
    Mar 5, 2013
    Posts:
    63
    Hello,

    My current trigger job doesn't work with RequireComponentTag. I didn't manage to find any documentation saying it shouldn't work with Physics world.

    Code (CSharp):
    1.     [BurstCompile]
    2.     //[RequireComponentTag(typeof(BulletTag))] //doesn't seem to work on Trigger jobs
    3.     private struct BulletCollisionJob : ITriggerEventsJob {
    4.  
    5.         public EntityCommandBuffer ecb;
    6.  
    7.         [ReadOnly]
    8.         public ComponentDataFromEntity<BulletTag> bulletEntities;
    9.  
    10.         public void Execute(TriggerEvent triggerEvent) {
    11.          
    12.             //we don't know if EntityA is a bullet or EntityB - unfortunately, RequireComponentTag doesn't work on Trigger jobs
    13.             if(bulletEntities.HasComponent(triggerEvent.Entities.EntityA)) {
    14.                 //spawn particles for bullet hit somehow
    15.                 ecb.DestroyEntity(triggerEvent.Entities.EntityA);
    16.             }
    17.  
    18.             if(bulletEntities.HasComponent(triggerEvent.Entities.EntityB)) {
    19.                 //spawn particles for bullet hit somehow
    20.                 ecb.DestroyEntity(triggerEvent.Entities.EntityB);
    21.             }
    22.  
    23.         }
    24.  
    25.     }
    Is this a mistake on my side? Or is it not supposed to work with this tag?

    I wanted this trigger to just trigger on my Entity with BulletTag, but it also triggers on another entity which doesn't contain such tag.

    Thanks in advance.
     
  2. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    The trigger events job just iterates through the events, not the entities themselves, so as you guessed using cdfe to check both is all that we can do for now.
     
  3. Quit

    Quit

    Joined:
    Mar 5, 2013
    Posts:
    63
    Thanks for your explanation.