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;
}
}