Game Development Community

Tank pack and vehicle resource

by Chris Kuykendall · in Torque Game Engine · 11/26/2005 (10:21 am) · 12 replies

Has anybody gotten the torque vehicle resource working with the bravetree tank pack? If so, how?

#1
11/26/2005 (12:49 pm)
Which resource are you talking about?
#2
11/26/2005 (12:53 pm)
This one, http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=3925, I have it working really well for turrets and vehicles, but when using it for the tank pack my log tells me no objects are found.
#3
11/26/2005 (1:58 pm)
I haven't gotten it to work but I have seen where the main problem comes from. The vehicle resource only looks for vehicles, which the tank is not.
#4
11/26/2005 (3:10 pm)
Yes, when I added the turret resource in I added a $typemask in the commands.cs where it searches for vehicles, but adding another for tankshape doesn't seem to be working
#5
07/16/2006 (1:39 am)
Have anybody a solution for it ? I have the same problem
#6
07/16/2006 (3:02 am)
Okay, I have a temp. solution to mount the tank using the TGE Vehicle resource. I have also noticed that the tank is a PlayerObject and not a VehicleObject. I'm not sure why its like that but here you go.

Just replace the whole function function serverCmdMountVehicle(%client) with this new one.

function serverCmdMountVehicle(%client)
{
   //Determine how far should the picking ray extend into the world?
   %selectRange = 3;

   // Search for vehicles and players that are mountable
   %searchMasks = ($TypeMasks::vehicleObjectType |
                   $TypeMasks::PlayerObjectType);
  
   %pos = %client.player.getEyePoint();

   // Start with the shape's eye vector...
   %eye = %client.player.getEyeVector();
   %eye = vectorNormalize(%eye);
   %vec = vectorScale(%eye, %selectRange);

   %end = vectorAdd(%vec, %pos);

   //%scanTarg = ContainerRayCast (%pos, %end, %searchMasks);
   %scanTarg = ContainerRayCast (%pos, %end, %searchMasks, %client.player); // Don't try mounting yourself

   // a target in range was found so select it
   if (%scanTarg)
   {
      %targetObject = firstWord(%scanTarg);
      echo("Found a vehicle: " @ %targetObject);
      onMountVehicle(%targetObject.getDataBlock(),
                     %client.player,
                     %targetObject);
   }
   else
   {
      echo("No object found");
   }
}

Then go to the vehicle.cs and changes this function function findEmptySeat(%vehicle, %vehicleblock)

function findEmptySeat(%vehicle, %vehicleblock)
{
   echo("This vehicle has " @ %vehicleblock.numMountPoints @ " mount points.");
   
   if (%vehicle.getClassName() $= "TankShape")
   {
      %node = %vehicle.getMountNodeObject(5);
      return 5;
   }
   for (%i = 0; %i <  %vehicleblock.numMountPoints; %i++)
   {
      %node = %vehicle.getMountNodeObject(%i);
      if (%node == 0)
      {
         return %i;
      }
   }
   return -1;
}

Hope this helps!
-Tek0
#7
07/19/2006 (6:11 pm)
Quote:
$TypeMasks::PlayerObjectType);

Wouldn't that mean players can mount other players? That can't be a good thing.
#8
07/19/2006 (6:16 pm)
@Tim,

I guess that would depend on what type of game you were making.
#9
07/19/2006 (6:18 pm)
LoL, that was a good one. =)
#10
07/19/2006 (8:42 pm)
@Tim,

No, players cant mount other players because the players doesnt have "mountable = true;".
#11
07/19/2006 (9:17 pm)
Well that's good to hear.
#12
07/19/2006 (9:32 pm)
I have been testing it out and it works out great.