I am so lost with this so any help much appreciated.
struct ListTriggerEventEntitiesJob : ITriggerEventsJob
{
[ReadOnly] public ComponentDataFromEntity<PhysicsVelocity> PhysicsVelocityGroup;
[ReadOnly] public ComponentDataFromEntity<TriggerVolume> VolumeGroup;
[NativeFixedLength(1)] public NativeArray<int> pCounter;
public NativeArray<TriggerEntities> TriggerEntities;
public void Execute(TriggerEvent triggerEvent)
{
Entity entityA = triggerEvent.Entities.EntityA;
Entity entityB = triggerEvent.Entities.EntityB;
bool isBodyATrigger = VolumeGroup.Exists(entityA);
bool isBodyBTrigger = VolumeGroup.Exists(entityB);
//Ignoring Triggers overlapping other Triggers
if (isBodyATrigger && isBodyBTrigger)
return;
bool isBodyADynamic = PhysicsVelocityGroup.Exists(entityA);
bool isBodyBDynamic = PhysicsVelocityGroup.Exists(entityB);
// Ignoring overlapping static bodies
if ((isBodyATrigger && !isBodyBDynamic) ||
(isBodyBTrigger && !isBodyADynamic))
return;
// Increment the output counter in a thread safe way.
var count = ++pCounter[0] - 1;
TriggerEntities[count] = new TriggerEntities()
{
VolumeEntity = isBodyATrigger ? entityA : entityB,
OverlappingEntity = isBodyATrigger ? entityB : entityA,
};
}
}
The main thing I am stuck on currently is
//Ignoring Triggers overlapping other Triggers
if (isBodyATrigger && isBodyBTrigger)
return;
Why is this ignored?
I thought ITriggerJob is triggered when two triggers collide so why ignore this when it happens???