I have a simple game where boxes move around on conveyer belts. When you click a conveyor, it rotates 90 degrees. When a conveyor rotates, I’d like for any boxes sitting on top of it to rotate with it.
To make this work, I have the boxes reparenting to the individual conveyors on initial contact. This seems to work fine and the boxes correctly move with the conveyor as expected; however, I’m noticing that it takes ~2 seconds after calling reparent for the box (child) transform to be affected by the conveyor (parent) transform.
This is somewhat game-breaking. I suspected that maybe there was some recursion happening in the scene but am not seeing a difference when I delete everything aside from a single conveyor and a single box.
Any idea why the reparent call would takes so long? Or alternative ideas?
The code is quite simple:
Conveyor.prototype.OnCollisionStart = function(result)
{
result.reparent(this.entity, 0);
};
I also tried (same result):
Conveyor.prototype.OnCollisionStart = function(result)
{
this.app.root.removeChild(result);
this.entity.addChild(result);
};