Dependancy issue since update

I am getting error:

However this wasn’t an Issue before updating to entities package 0.0.23.
Code is quite simple, and doesn’t appear to be writing to the same objects:
(The error is flagged to line 65)

public class PlayerMovementSystem : JobComponentSystem
{
    [RequireComponentTag(typeof(Player))]
    public struct PlayerMovementJob : IJobProcessComponentData<Translation, Rotation>
    {
        [ReadOnly] public float speed, move_x, move_z;
        [ReadOnly] public float dt;
        [ReadOnly] public float3x2 bounds;

        public void Execute(ref Translation position, [ReadOnly] ref Rotation rotation)
        {
            float3 newPos = math.forward(rotation.Value) * speed * dt * move_z;
            float3 newPosx = ((Quaternion)rotation.Value * new float3(1, 0, 0)) * speed * dt * move_x;
            position.Value = position.Value + newPos + newPosx;
        }
    }

    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var piSystem = World.GetExistingManager<PlayerInputSystem>();
        if (!piSystem.Initialised) return inputDeps;
        var pi = piSystem.PlayerInput;

        var handle = new PlayerMovementJob()
        {
            move_x = pi.MoveX,
            move_z = pi.MoveZ,
            dt = Time.deltaTime,
            speed = 100

        }.Schedule(this, inputDeps);
        var handle2 = new Jobs.PlayerRotationJob()
        {
            pan = pi.Pan,
            tilt = pi.Tilt,
            dt = Time.deltaTime,
            rotateSpeed = 100


        }.Schedule(this, handle);
        return handle2;
    }
}

[UpdateAfter(typeof(PlayerInputSystem))]
public class PlayerCursorMovementSystem : JobComponentSystem
{
    [RequireComponentTag(typeof(PlayerCursor))]
    public struct PlayerCursorMovementJob : IJobProcessComponentData<Translation>
    {
        [ReadOnly] public float3 cursorPos;
        [ReadOnly] public float3x2 bounds;

        public void Execute(ref Translation position)
        {
            position.Value = cursorPos;
        }
    }

    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var piSystem = World.GetExistingManager<PlayerInputSystem>();
        if (!piSystem.Initialised) return inputDeps;

        var handle = new PlayerCursorMovementJob()
        {
            cursorPos = piSystem.PlayerInput.MousePositionOnTerrain
        }.Schedule(this, inputDeps);

        return handle;
    }
}

I assume you mean 0.0.12 preview 26 that was released today.

Anyway I can’t see anything wrong with your systems.

What group is your PlayerInputSystem being updated? Just the default?
Are you doing custom loop initialization?
Any warnings?

1 Like

Ah Yes, sorry took the number from the Samples ReleaseNotes.md

What group is your PlayerInputSystem being updated? Just the default? Default
Are you doing custom loop initialization? No
Any warnings? No

I am thinking that this is because Player and PlayerCursor are just tags are shared components and it’s something to do with the optimisations done around tag only shared components components.

Update: I changed the code to use ComponentsGroups and .ScheduleGroup on the jobs. This pointed the error elsewhere: (Or solved the issue allowing for this one to to be raised)

public class PlayerCursorPositionUpdateSystem : ComponentSystem
{

    protected override void OnUpdate()
    {
        ForEach((Entity e, PlayerCursor playerCursor, ref Translation position) =>
            {
                playerCursor.GameObject.transform.position = position.Value;
            });
    }
}

I used a ComponentSystem here has updating the position can only be done on the main thread. I should probably use the built in transform systems or a JobComponentSystem so it gets inputDeps. Not sure how I will do this going forward as the gameObject is just a placeholder for now.