Hi everyone,
I’m trying to implement a system to move items on belts.
And I’m really struggling to find a good solution to make it work in a Job and use multi-thread.
Here are my components:
public struct GridNode : IComponentData
{
}
public struct GridCoord : IComponentData, IEquatable<GridCoord>
{
public int2 Value;
public GridCoord(int x, int y)
{
this.Value = new int2(x, y);
}
public static implicit operator float3(GridCoord d)
{
return new float3(d.Value.x, 0, d.Value.y);
}
public bool Equals(GridCoord other)
{
return this.Value.Equals(other.Value);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
return obj is GridCoord && Equals((GridCoord)obj);
}
public override int GetHashCode()
{
return this.Value.GetHashCode();
}
}
public struct ConveyorPusher : IComponentData
{
public Directions Direction; //East,North,West,North
}
public struct ConveyorMovable : IComponentData
{
}
public struct ConveyorAcceptMovable : IComponentData
{
}
And my Entities Archetypes:
- Empty Tile: GridNode / GridCoord (WHITE)
- Tile with Conveyor Belt: GridNode / GridCoord / ConveyorPusher / ConveyorAcceptMovable (YELLOW)
- Objects that needs to be transported: GridCoord / ConveyorMovable (RED)
And a little drawing:

I tried many different things in jobs, but most of the time I was block because I could read / write at the same time in a job.
So, maybe someone will have a good solution, or already done something similar and know the gotchas.
Important info:
Every objects (red) move at the same time, 1 tile in the direction of the Pusher, each turn, if the targeted tile has an ConveyorAcceptMovable component. (It is not a like in Factorio, realtime moving system )
The drawing shows the current state of the Grid.
I need to figure out which boxes can move, cannot move.
And that’s the hard part. Since data can be accessed randomly. For instance:
- C5 is an intersections, so only B5 or C4 can go in C5. (already, kind of race condition, who wins ? )
- B3 can only move if C3 moves. C3 can moves only if C4 moves. And most importantly only if C4 had received priority over B5 at intersection C5
You can start to see that everything is connected at different places…
Which gave me a headache for some days now…
The problem is not trivial but not super hard if you do everything in a single thread.
But I don’t think I have enough XP yet using Jobs to handle something like that.
So if someone has some pointers, that’ll be awesome.
Also if you want a small challenge ![]()
Thanks everyone




