Game Development Community

Does starter.racing work in multiplayer mode?

by Tim Hutcheson · in General Discussion · 04/05/2005 (7:00 pm) · 14 replies

I just tried running the starter.racing demo on the LAN, after running the starter.fps demo just fine, and found that it behaves oddly. The server sarts up normally and looks fine but when another workstation runs the engine and joins the server, the client suddenly has a view that seems like a dis-embodied camera floating amid a broken terrain.

To verify this, I loaded both wokstations with freshly compiled copies of the TGE 1.3 distro. Works fine in multiplayer when running the FPS stuff but not the Racing demos.

Anyone else seen this behavior? Any clues?

#1
04/05/2005 (8:37 pm)
I think it is because there is only one spawn point...I think. You can easily add another...copy paste.
#2
04/06/2005 (5:46 am)
No, I'm certain it's seeing three spawn points defined in the mission file because I added messages to the pickSpawnPoint function in game.cs to be sure. But thanks for the suggestion.


I now notce that if I fly the client camera up and look down at the race track, none of the track objects are in the terrain. So it seems that it's not loading any objects at all, just the terrain. Hmmmm...

Any ideas?
#3
04/06/2005 (9:33 am)
Well, I only say that because a very similar problem happened to me when LANing, but I could see the other player and everything in the track was there. Who ever was connecting to the server was the one that would have the camera in the ground. As soon as I added a spawnpoint, it never happened again. You may have a different issue though...good luck. Post up if you find the answer. :)
#4
04/06/2005 (9:43 am)
I've never had a problem with it in Multiplayer mode
#5
04/06/2005 (9:59 am)
Really? Describe what happens when the first client joins the game. Where does it spawn the second buggy? The three spawn points I see in the mission have it spawning vehicles about 10 meters apart. Does it do that for you? Are you using the standard 1.3 distribution download or the latest CVS version? Still puzzled...
#6
04/06/2005 (10:12 am)
I've just been using the standard torque Demo app, running starter.racing hosting multiplayer on the first machine, and have the others do a lan query to join the game.

After they join they all spawn really close together, and we try not to flip the buggies as we race around the track.

I dunno, it works as expected in Multiplayer on my lan (no firewall all direct connected to a router).

Maybe I'm missing something?
#7
04/06/2005 (10:15 am)
Oh ok, I see the difference here. (Duh) I was using a game that I was modifying from the starter.racer. I had a clean mission file that only had one spawn point. But the result was very similar. We both had that camera floating around in the level during multiplayer. Not sure then. So your right, it must be a different problem.
#8
04/06/2005 (11:25 am)
Dreamer: Thanks for that input. Knowing that it works for some may help in figuring out why it doesn't work for me.
#9
04/10/2005 (8:00 am)
@Tim
I had the exact same problems as you. I don't know how anyone gets multiplayer to work for the racing demo. I think I found the problem in the script.

I looked at /sever/scripts/game.cs

function GameConnection::onClientEnterGame(%this)
{
...
if(!$Game::Running)
{
// Create a car object.
%this.spawnCar();

// Orbit the camera around the car
%this.camera.setOrbitMode(%this.car, %this.car.getTransform(), 0.5, 4.5, 4.5);
}
...
}

The problem is if a player joins after the game has started. Then the spawnCar() function won't be called. As a hack I commented out the if statement and forced the spawnCar() call. I had to press Alt-C to get keyboard focus for the car, but it worked. It has nothing to do with the spawn points. Even if you have one spawn point all of the cars should just pile on top of each other.

Now I need to make a cleaner fix.

Brian
#10
04/10/2005 (8:07 am)
Hey that's great Brian. Could you tell me if the other scene objects are rendering? When I flew the camera around the terrain I only saw the "muddy" track, after finding the track somewhere in the mountains, BTW.

Tim
#11
04/10/2005 (11:42 am)
Yes, I can see all of the objects in the scene. When you run single player mode do you see all of the scene objects? Does your console display any error messages? Does the second car 'spawn' for you now?


Here is my command line
torqueDemo.exe -console -game starter.racing

I changed the code to this

// if(!$Game::Running)
// {
echo("Creating car");
// Create a car object.
%this.spawnCar();

// Orbit the camera around the car
%this.camera.setOrbitMode(%this.car, %this.car.getTransform(), 0.5, 4.5, 4.5);
// }
#12
04/10/2005 (10:22 pm)
The reason why I did that is because most of the time for racing games you don't want people to pop in while the race is running, of course this should be complemented with a game lobby, but for the starter kit purposes the idea that came out from a conversation with TimG was to do it that way, It has a small time at the start, that you can easily tweak from the scripts in which it will wait for new players, after the race starts, there's no more joining. It obviously might not fit your needs, but that's what most racing games do, so I went in that direction. An addition to it could be a dialog on the server/administrator that tells the game when to start the race and stop waiting for players. Your call.
#13
04/11/2005 (5:13 am)
Thanks, Xavier. I just never got the idea of the countdown time being the "lobby" time and can easily see what you meant now. I think if the server let late joiners know that the race has started, and they won't get a car, then the distribution code would be complete in this regard.
#14
07/24/2007 (5:55 am)
Tese are my modification to GameConnection::onClientEnterGame( %this ) in order to start a multiplayer game :

function GameConnection::onClientEnterGame(%this)
{
commandToClient(%this, 'SyncClock', $Sim::Time - $Game::StartTime);
commandToClient(%this, 'SetMaxLaps', $Game::Laps);

// Create a new camera object.
%this.camera = new Camera() {
dataBlock = Observer;
};
MissionCleanup.add( %this.camera );
%this.camera.scopeToClient(%this);

// Client controls the camera by default.
%this.setControlObject(%this.camera);

// if(!$Game::Running)
// {
// Create a car object.
%this.spawnCar();

// Orbit the camera around the car
%this.setControlObject(%this.car);
%this.camera.setOrbitMode(%this.car, %this.car.getTransform(), 0.5, 4.5, 4.5);
// }
}

I had to add the setControlObject() in order for me to start controlling the new car.