Hello,
I am attempting to create a multiplayer game that utilizes Box2D as a physics engine. At my current stage of development, my goal is to simply have one player's screen 'mirror' the other player's screen.
On the 'Controller' screen, individual bodies stacked in a column can be destroyed, and I want the resulting collapses to properly display on both the Controller screen and the Spectator screen. To accomplish this, I am building the same level for both players, and then attempting to pass the body that has been destroyed by the Controller to the Spectator so that it can destroyed there too.
The issue is that the method I am using to deliver the target body to the spectator is not working. I am using remote shared objects, and the body I pull out of the shared object on the spectator side does not seem to function properly.
Below is the code I use on the Controller side to destroy bodies:
Obviously targettingSO is my shared object, which has already been properly configured at this point. This DOES work. However, the code below on the Spectator end of things does not work:
I have tried a number of variations of this, such as casting targettingSO.data.body as a b2Body object and passing that to the DestroyBody method, but no dice. No matter what I do, it actually seems to cause the program to hang, as alert statements after that call to DestroyBody never execute. It was my assumption that a body passed like this between two different instances of the same program would be usable in this way, but my best guess now is that the body on the Controller end is not identical to the body on the Spectator end, even though they are in the sense of the game.
Could anyone offer any advice as to how I might accomplish this transfer of information from one client to the other?
I am attempting to create a multiplayer game that utilizes Box2D as a physics engine. At my current stage of development, my goal is to simply have one player's screen 'mirror' the other player's screen.
On the 'Controller' screen, individual bodies stacked in a column can be destroyed, and I want the resulting collapses to properly display on both the Controller screen and the Spectator screen. To accomplish this, I am building the same level for both players, and then attempting to pass the body that has been destroyed by the Controller to the Spectator so that it can destroyed there too.
The issue is that the method I am using to deliver the target body to the spectator is not working. I am using remote shared objects, and the body I pull out of the shared object on the spectator side does not seem to function properly.
Below is the code I use on the Controller side to destroy bodies:
Code:
if (world.GetBodyList().IsAwake() == false)
{
Main.targettingSO.setProperty("body", body);
world.DestroyBody(Main.targettingSO.data.body);
}
{
Main.targettingSO.setProperty("body", body);
world.DestroyBody(Main.targettingSO.data.body);
}
Obviously targettingSO is my shared object, which has already been properly configured at this point. This DOES work. However, the code below on the Spectator end of things does not work:
Code:
if (targettingSO.data.body != null)
{
currentLevel.world.DestroyBody(targettingSO.data.body);
}
{
currentLevel.world.DestroyBody(targettingSO.data.body);
}
I have tried a number of variations of this, such as casting targettingSO.data.body as a b2Body object and passing that to the DestroyBody method, but no dice. No matter what I do, it actually seems to cause the program to hang, as alert statements after that call to DestroyBody never execute. It was my assumption that a body passed like this between two different instances of the same program would be usable in this way, but my best guess now is that the body on the Controller end is not identical to the body on the Spectator end, even though they are in the sense of the game.
Could anyone offer any advice as to how I might accomplish this transfer of information from one client to the other?