I am having an issue with Unity correctly reading position changes (and destroying) of GameObjects. I have attached a sample project.
In the project, there are three platforms and two cubes. If you click (tap) a cube, it will be selected. Click it again to deselect. Click on an empty space when a cube is selected and it will move there and get deselected.
Each platform has a label telling you whether it is occupied or not. This gets updated on two occasions:
A) If any platform or cube is clicked, the status of all cubes and platforms is updated before performing any logic, to have an accurate response. This works as it should.
B) If a cube is selected and you click an empty space, the label gets updated a second time after the cube has moved, to reflect the new state of things. This is where the problem creeps in.
The cube moves and gets deselected, as it should, but the labels on the platforms don’t update, until you click something again!
I put some debug Print() statements in the code, which gives the expected output:
3x “occupants updated.”
1x “cube moved.”
3x “occupants updated.”
3x “UI updated.”
So that means the code for updating occupants (which includes performing an OverlapBox test) and updating the UI does run after the cube was moved, but it still shows the old information before the move.
What gives?
Any suggested solutions to this?
Cheers!
6940553–815731–Timing Bug.zip (728 KB)