Is the "RTS Prototype" suitable for multiple player(LAN Mode)?
by Tom Giant · in Torque 3D Professional · 11/18/2010 (5:30 am) · 3 replies
I tested part of the function mentioned in the chapter "Scripting->Advanced->RTS Prototype" of the official documentation. I found there was no any problem to direct the "BoomBot" by clicking the mouse right button when the game was launched as single mode or launched as the host in the case of multiple players.
But there was a big problem when the game as a client was launched and connected to a host or a dedicated server. It was that the "BoomBot" of the client-side couldn't be controled by clicking the mouse right button. I traced the codes and confirmed the function "PlayGui::onRightMouseDown" to have been called. Then I was confused. Did I do something wrong? Or this tutorial is just a limited prototype, I have to improve it for the network mode. Does anyone have some experiences about that?
Thanks for any help in advance.
But there was a big problem when the game as a client was launched and connected to a host or a dedicated server. It was that the "BoomBot" of the client-side couldn't be controled by clicking the mouse right button. I traced the codes and confirmed the function "PlayGui::onRightMouseDown" to have been called. Then I was confused. Did I do something wrong? Or this tutorial is just a limited prototype, I have to improve it for the network mode. Does anyone have some experiences about that?
Thanks for any help in advance.
About the author
#2
See this thread http://www.torquepowered.com/community/forums/viewthread/106997
11/18/2010 (7:08 am)
The RTS prototype does not work correctly in multiplayer. See this thread http://www.torquepowered.com/community/forums/viewthread/106997
#3
I made some changes to the stock codes of the official document, then the "BoomBot" could be directed in the multiple player mode. But I don't know whether or not the changes are appropriate and safe.
function PlayGui::onRightMouseDown(%this, %pos, %start, %ray)
{
// find end of search vector
%ray = VectorScale(%ray, 2000);
%end = VectorAdd(%start, %ray);
// only care about terrain objects
%searchMasks = $TypeMasks::TerrainObjectType;
// search!
%scanTarg = ContainerRayCast( %start, %end, %searchMasks );
// If the terrain object was found in the scan
if( %scanTarg )
{
ClientGroup.getObject(0).player.setMoveDestination( getWords(%scanTarg, 1, 3) );
}
else
{
commandToServer('RightMouseDown', %start, %end );
}
}
function serverCmdRightMouseDown(%client, %start, %end)
{
// only care about terrain objects
%searchMasks = $TypeMasks::TerrainObjectType;
// search!
%scanTarg = ContainerRayCast( %start, %end, %searchMasks );
// If the terrain object was found in the scan
if( %scanTarg )
{
// Get our player/actor
%ai = %client.player;
%ai.setMoveDestination( getWords(%scanTarg, 1, 3) );
}
}
11/29/2010 (8:51 am)
Thanks for your replies.I made some changes to the stock codes of the official document, then the "BoomBot" could be directed in the multiple player mode. But I don't know whether or not the changes are appropriate and safe.
function PlayGui::onRightMouseDown(%this, %pos, %start, %ray)
{
// find end of search vector
%ray = VectorScale(%ray, 2000);
%end = VectorAdd(%start, %ray);
// only care about terrain objects
%searchMasks = $TypeMasks::TerrainObjectType;
// search!
%scanTarg = ContainerRayCast( %start, %end, %searchMasks );
// If the terrain object was found in the scan
if( %scanTarg )
{
ClientGroup.getObject(0).player.setMoveDestination( getWords(%scanTarg, 1, 3) );
}
else
{
commandToServer('RightMouseDown', %start, %end );
}
}
function serverCmdRightMouseDown(%client, %start, %end)
{
// only care about terrain objects
%searchMasks = $TypeMasks::TerrainObjectType;
// search!
%scanTarg = ContainerRayCast( %start, %end, %searchMasks );
// If the terrain object was found in the scan
if( %scanTarg )
{
// Get our player/actor
%ai = %client.player;
%ai.setMoveDestination( getWords(%scanTarg, 1, 3) );
}
}
Torque 3D Owner GameArt Studio GmbH
Default Studio Name