How to control/make building on server
by Paulo Coutinho · in Torque Developer Network · 12/14/2009 (2:07 am) · 1 replies
Hi.
When you build a multiplayer RTS game, you need that the server control the buildings/players/units.
So, how Torque3D control it on server?
Today, im doing it:
1 - When client click to build, it send a command to server (ex):
commandToServer('buildXXXX', $Mouse::posVector);
2 - Server receive it and build (ex):
function serverCmdbuildTower(%client, %posVector)
{
%obj = new StaticShape()
{
position = %posVector;
dataBlock = "BldTower";
scale = "0.5 0.5 0.5";
};
%client.player.buildings[%client.player.buildingCount] = %obj;
MissionCleanup.add(%obj);
echo("--------NEW BUILDING---------");
echo(%client.player.buildings[%client.player.buildingCount]);
echo("-----------------------------");
%client.player.buildingCount++;
}
But on my game test, the building process is normal and the model is built on correct place, but on multiplayer game the server will create it on all connected clients?
If i build a datablock(player/building/unit) on server it automacally send all to connected clients?
When you build a multiplayer RTS game, you need that the server control the buildings/players/units.
So, how Torque3D control it on server?
Today, im doing it:
1 - When client click to build, it send a command to server (ex):
commandToServer('buildXXXX', $Mouse::posVector);
2 - Server receive it and build (ex):
function serverCmdbuildTower(%client, %posVector)
{
%obj = new StaticShape()
{
position = %posVector;
dataBlock = "BldTower";
scale = "0.5 0.5 0.5";
};
%client.player.buildings[%client.player.buildingCount] = %obj;
MissionCleanup.add(%obj);
echo("--------NEW BUILDING---------");
echo(%client.player.buildings[%client.player.buildingCount]);
echo("-----------------------------");
%client.player.buildingCount++;
}
But on my game test, the building process is normal and the model is built on correct place, but on multiplayer game the server will create it on all connected clients?
If i build a datablock(player/building/unit) on server it automacally send all to connected clients?
Torque 3D Owner mb