Game Development Community

multiplayer car game for education torque 3D

by Aaron Agius · in Torque 3D Beginner · 06/20/2013 (5:13 am) · 10 replies

Hi team,
I am trying to create a learning activity where students can modify an already built vehicle in 3ds max and then drive them around in an environment for multiplayer hijinx.

So I am an educator and although I know this is a good idea I unfortunately have not much skill to make it happen. My original idea was to mod think tanks, but I am using max 2013 and cannot find a way to interact with the .dts files that are used.

Here is the reply from Mich at Garage Games..
Hey Aaron,

Vehicle multiplayer still works fine in Torque 3D. While not a traditional car, the Cheetah in T3D shows all the required pieces to make a functional vehicle, just like the buggy from TGE. It was built entirely in 3DS Max, then exported to COLLADA. T3D natively loads COLLADA files, then converts them to DTS in the background.

You could take the T3D demo, disable all weapons, then have players automatically start in a Cheetah to have a base racing game. All you would need to do after that is to add the script functionality to start a race, time it, and end the race. Of course, if you do not want to use the Cheetah, you will need to create a different vehicle and export it to COLLADA.

I hope this helps. If you need more help, post a thread on our forum and reply to this thread with a link. That way we can continue the discussion there and have other T3D users helps out.

Regards,
Mich

OK so I don't need to start or end the race, just getting everyone to drive around will be fine, but I cannot find a multiplayer example in the T3D.. the only thing I get is FPS example..
Please help I feel that I am close to being able to do this, but oh still so far away..
All I want to do is 1) be able to modify the cheetah,
2) be able to get some players onto those sand dunes and drive around! (making terrain and other stuff can come later!)

Cheers all!
Thanks for any and all help.
sub

#1
06/20/2013 (5:49 am)
@Aaron - T3D is always running multiplayer, you just need a GUI to host a game and one to join a server.

Have you checked out the FPS tutorial for T3D? You can read it here. Everything in T3D 1.2 and Torque 3D MIT has all the networking GUIs and scripts you will need. This includes a GUI for starting and joining a server, which is the first step you are looking at.

The only things that make the stock script code a FPS are:

1. You start off as the soldier
2. You have weapons
3. You can get in and out of vehicles

You need to modify the scripts and levels to have a player start off in a vehicle, instead of on foot. Then you need to disable the keybinding that allows a player to get out of the vehicle.
#2
06/20/2013 (5:54 am)
ok so I need a little more help, I can see how I can edit the collada assets in 3ds max, but when I save the assets I don't see the changes in the t3d engine. I guess I have been put off by the FPS tutorials because I am trying to stay away from fps, but i will go and have a closer look... Still, I know this is a good idea, but I am a bit out of my depth trying to get it to work. Any further hints you guys can give me on how exactly to set up the multiplayer and how exactly to edit the cheetah models would be really, really greatly appreciated.Thanks for your help,I guess I have some serious homework to do.Cheerssub
#3
06/20/2013 (6:25 am)
When a COLLADA file is first loaded, it is cached in DTS form. The engine will then use that DTS file. When you make a change to the COLLADA file, you need to delete the cached DTS to see the changes.

As for the tutorial, try to look past the FPS part. You can get a lot of useful information from it. You do not have to implement anything related to guns. The tutorial covers scripting, GUIs, networking, the editors, and more.

I do not have T3D installed on this machine, so hopefully another user can jump in to point out some specific scripts to start modifying.
#4
06/20/2013 (6:30 am)
yeh thanks Micheal, I have been deleting the .dts files after changing the collada ones, its just not working for me at the moment.. but I am just still unsure as to where the actual files are being pulled from.. I will go back to the drawing board tomorrow and see if I can work it out.
Thanks for your help, I still need some more help for getting the multiplayer working but I will keep on trying to see if I can make it work.
Thanks again,
I look forward to seeing if anyone else out there can help me further.
Cheers all
sub
#5
06/20/2013 (9:47 am)
Aaron@

You can use the <Project>\DeleteCachedDTSs.bat script to clean up all the cached models.

They are normally saved under <Project>\game\art\shapes\<somewhere>

So after exporting them to proper directory and clearing any cached models....

Then fire up the T3D "game" and enter the "world editor" mode ... with an empty level.
(or play the level and hit F11, same thing)

If you then look at the line of icons under the context menu's will see the last icon looks like a 3D box or such.

This tool lets you; "browse" the 3D models, make sure they import correctly, test the animations and make sure the textures are mapped properly.

Now to disable the weapons ... thats fairly easy and likely many ways to go about it;
one way it to edit the file : <Project>\game\art\datablocks\player.cs

and at the bottom, where it assigns weapons ... comment it out;
// Allowable Inventory Items
  // mainWeapon = Lurker;

//   maxInv[Lurker] = 1;
//   maxInv[LurkerClip] = 20;

//   maxInv[LurkerGrenadeLauncher] = 1;
//   maxInv[LurkerGrenadeAmmo] = 20;

 //  maxInv[Ryder] = 1;
 //  maxInv[RyderClip] = 10;

//   maxInv[ProxMine] = 5;

  // maxInv[DeployableTurret] = 5;

And in the same file, you could replace the player model -- with that of a vehicle.
shapeFile = "art/shapes/actors/Soldier/soldier_rigged.dae";

I don't have latest code-base in front of me at the moment (am on a mac) but believe that would do the trick.

And there are likely a dozen better ways to do this as well ... just trying to help get you started.
#6
06/20/2013 (9:58 am)
On second thought, here is the torque script code it uses to "mount" a player into a vehicle ...

<Project>/game/scripts/server/players.cs
function Armor::onMount(%this, %obj, %vehicle, %node)
{
   // Node 0 is the pilot's position, we need to dismount his weapon.
   if (%node == 0)
   {
      %obj.setTransform("0 0 0 0 0 1 0");
      %obj.setActionThread(%vehicle.getDatablock().mountPose[%node], true, true);

      %obj.lastWeapon = %obj.getMountedImage($WeaponSlot);
      %obj.unmountImage($WeaponSlot);

      %obj.setControlObject(%vehicle);
      
      if(%obj.getClassName() $= "Player")
         commandToClient(%obj.client, 'toggleVehicleMap', true);

And it looks like the GameCore::loadout function assigns weapons by default ... so my previous suggestion won't help. But if you open <Project>/game/scripts/server/gameCore.cs and just comment out the sections as follows -- it ought to disable the player weapons.

function GameCore::loadOut(%game, %player)
{
   //echo (%game @"\c4 -> "@ %game.class @" -> GameCore::loadOut");

   %player.clearWeaponCycle();
/*   
   %player.setInventory(Ryder, 1);
   %player.setInventory(RyderClip, %player.maxInventory(RyderClip));
   %player.setInventory(RyderAmmo, %player.maxInventory(RyderAmmo));    // Start the gun loaded
   %player.addToWeaponCycle(Ryder);

   %player.setInventory(Lurker, 1);
   %player.setInventory(LurkerClip, %player.maxInventory(LurkerClip));
   %player.setInventory(LurkerAmmo, %player.maxInventory(LurkerAmmo));  // Start the gun loaded
   %player.addToWeaponCycle(Lurker);

   %player.setInventory(LurkerGrenadeLauncher, 1);
   %player.setInventory(LurkerGrenadeAmmo, %player.maxInventory(LurkerGrenadeAmmo));
   %player.addToWeaponCycle(LurkerGrenadeLauncher);

   %player.setInventory(ProxMine, %player.maxInventory(ProxMine));
   %player.addToWeaponCycle(ProxMine);

   %player.setInventory(DeployableTurret, %player.maxInventory(DeployableTurret));
   %player.addToWeaponCycle(DeployableTurret);
   
   if (%player.getDatablock().mainWeapon.image !$= "")
   {
      %player.mountImage(%player.getDatablock().mainWeapon.image, 0);
   }
   else
   {
      %player.mountImage(Lurker, 0);
   }
 */
}

And then add in there some code to (a) first spawn a vehicle at the players position and then (b) use the previous code example to mount player into said vehicle.

that ought to do the trick!
#7
06/20/2013 (2:16 pm)
Cheers Jeff,
I will get onto it and see what I can do!
Thanks for helping
#8
06/20/2013 (5:49 pm)
Hey so I am now trying to do the FPS tutorial but my T3d is acting different. When I create a new project I only get 2 choices full or empty. I don't get a FPS choice with multiplayer etc...
I look forward to finding out what I am doing wrong here!
Cheers
#9
06/21/2013 (12:49 pm)
Just copy the Template\Full over to My Project\Full ... the tutorial is based upon the previous versions with the project tool built into it.

To try out Multiplayer, over the LAN is simple ... start up T3D on 2 PCs on same network and on first PC when starting the level click the checkbox for "host game".

and on the other pc, click JOIN (not PLAY) and hit QUERY LAN.
#10
06/21/2013 (2:18 pm)
To spawn as a car ... found this by searching the site.

www.garagegames.com/community/forums/viewthread/98599

And just tried it on a level, modified the spawn sphere marker;
new SpawnSphere() {
         spawnClass = "WheeledVehicle";    // 
         spawnDatablock = "CheetahCar";    //

Now I spawn into the level as a cheetah ... just hit TAB to switch the camera to 3rd person view, as the few from inside the car isn't so great.