I have a multiplayer game that has the feature that when object A and object B collide, one is destroyed, leaving only object B.
Before any action, both players see object A and B in the correct place.
If player 1 collides object A and B, player 1 sees them collide and sees A get destroyed.
If player 2 is active, and watches as player 1 collides object A and B, player 2 also sees A get destroyed.
If player 1 collides object A and B while player 2 is inactive (switched away from the tab), when player 2 switches back, player 2 will NOT see that entity A was destroyed. In fact, entity A still exists in the scene.
Debug logs confirm that the destroy() method was called, but it had no effect because it “happened” when the player was not on the tab.
Has this happened to anyone else? Any way to ensure objects get destroyed even if player is not active? My default solution would be to create a “destroy buffer” and only execute the destruction when the user is “active” but this feels pretty hacky … not sure why playcanvas will not allow logic to be executed successfully when player in inactive (but console logs still execute normally)
Another way to describe what is happening: Player 1 executes an event that propagates to server, and NodeJS server propagates that event to all players including player 2. Player 2 was not active when this propagation happened. Debug logs in the target function on player 2’s console still appear in chrome console, but any playcanvas actions like entity.destroy() that were called while player 2 was not on the tab are ignored.