2 players/gameconnections on the same time
by Mathieu · in Torque Game Engine · 09/09/2003 (10:01 am) · 1 replies
Hi all,
I'm trying to figure out how to spawn 2 players on the same application.
I need that each player use his own GameConnection.
I've tried a lot of things but I'm stuck.
For example if I use this :
Any idea?
- sorry for my english, frenchy frog -
I'm trying to figure out how to spawn 2 players on the same application.
I need that each player use his own GameConnection.
I've tried a lot of things but I'm stuck.
For example if I use this :
//1st player
createServer(%serverType, %mission);
%conn = new GameConnection(ServerConnection);
RootGroup.add(ServerConnection);
%conn.setConnectArgs($pref::Player::Name);
%conn.setJoinPassword($Client::Password);
%conn.connectLocal();
//2nd player
%client2 = new GameConnection(ClientConnection);
RootGroup.add(ClientConnection);
%client2.setConnectArgs("Boby");
%client2.connect("localhost");Just before the game start I had a "The connection to the server time out" for the second player...Any idea?
- sorry for my english, frenchy frog -
About the author
Developer at frogames.com / frogames.net
Torque Owner Jared Schnelle
This was a project I was working on in march, so I'm a tad rusty on how everything flowed.
I created the 2nd player in game, though.
I'd load up with 1 player, then hit a button to load up the second player. When I did that I could hit another key ('E') to switch focus between the two players.
Anyhow, here is the code that I used to load the second player, once in game.
function createSecondPlayer(%client) { %spawnPoint = pickSpawnPoint(); // Create the player object %player = new Player() { dataBlock = $PlayerDatablockName; client = %client; }; MissionCleanup.add(%player); // Player setup... %player.setTransform(%spawnPoint); %name = "PlayerTwo"; %player.setShapeName(%name); %client.setPlayerTwo(%player); }You wont have a %client.setPlayerTwo(); function, because that's one I made to save off the pointer to the player, so I could switch between them in game. Everything else should work for you.
Good luck.