ITriggerEventsJob not triggering/scheduled in 0.51

hi,

iam trying to revive an old project, which i tried to migrate to ecs 0.51, but half way into the process i stopped so i really dont know where i left off. I noticed that the following ITriggerEventsJob is not scheduled/executed (you can see the debug.log message is not executed).

Is there anything iam missing here? I checked this migration document but i dont see any difference (except “BufferBase” but this is just a super light wrapper, you can see it below).

Iam trying to upgrade to 1.0, but i first want to get everything working until i work to the next upgrade

[UpdateAfter(typeof(StepPhysicsWorld))]
  [UpdateBefore(typeof(EndFramePhysicsSystem))]
  [UpdateInGroup(typeof(FixedStepSimulationSystemGroup))]
  public partial class CoreTriggerSystem : BufferBase<EndSimulationEntityCommandBufferSystem>
  {
    private StepPhysicsWorld _stepPhysics;
    private EndFramePhysicsSystem _endFramePhysicsSystem;

    protected override void Create()
    {
      _stepPhysics = World.GetOrCreateSystem<StepPhysicsWorld>();
    }

    protected override void Update(EntityCommandBuffer cmdBuffer)
    {
      var collisionEventJob = new CollisionEventJob()
      {
          //stuff
      };

      Dependency = collisionEventJob.Schedule(_stepPhysics.Simulation, Dependency);
    }
  }

  internal struct CollisionEventJob : ITriggerEventsJob
  {
    public void Execute(TriggerEvent triggerEvent)
    {
      Debug.Log("hello!");
      ProcessEntity(triggerEvent.EntityA, triggerEvent.EntityB);
      ProcessEntity(triggerEvent.EntityB, triggerEvent.EntityA);
    }
}

BufferBase:

public partial class  BufferBase<TBuffer> : SystemBase where TBuffer : EntityCommandBufferSystem
  {
    private TBuffer _commandBufferSystem;
    protected virtual void Create() { }
    protected virtual void Update(EntityCommandBuffer cmdBuffer) { }

    protected override void OnCreate()
    {
      Create();
      _commandBufferSystem = World.GetOrCreateSystem<TBuffer>();
    }

    protected override void OnUpdate()
    {
      var commandBuffer = _commandBufferSystem.CreateCommandBuffer();
      Update(commandBuffer);
      _commandBufferSystem.AddJobHandleForProducer(Dependency);
    }
  }

If you don’t want to upgrade to 1.0, you could have a look at this old version of the PhysicsSamples project based on 0.51.
There is an example in there here which uses an ITriggerEventsJob.

I don’t see any immediate difference between the example and your case. All I can think of is maybe that there is simply no event triggered in your scene and therefore there is no trigger event to call the Execute function on in your job.

1 Like

Thanks for pointing me to the repository! The following line was missing:

protected override void OnStartRunning()
{
    this.RegisterPhysicsRuntimeSystemReadOnly();
}
1 Like

Subtle! That’s not needed in 1.0 anymore :).
I’m glad you got it to work.