Game Development Community

Wheeled Vehicle Tires

by Kevin Ostrowski · in Torque Game Engine · 03/04/2002 (5:50 pm) · 11 replies

I've made a few different Wheeled Vehicles and have no problem getting them into Torque, the only problem is that every model is using the same tire and tire physics, it always uses the tire from whatever vehicle is last exec'd in game.cs. I swear I have different names for everything, I've checked it over about 100 times but can't seem to figure it out. Is this just how it works? It doesn't look like it should:

function WheeledVehicleData::onAdd(%this,%obj)
{
// Setup the car with some defaults tires & springs
for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) {
%obj.setWheelTire(%i,DefaultCarTire);
%obj.setWheelSpring(%i,DefaultCarSpring);
}
}

Isn't that creating the car with DefaultCarTire & DefaultCarSpring? Has anyone else gotten different tires in?

#1
03/04/2002 (7:35 pm)
I have not tried this myself but I beleive you need to do something liek the following.

In your vehicle datablock add the following

tyreType = "NewTire";
springType = "NewSpring";

function WheeledVehicleData::onAdd(%this,%obj) 
{ 
// Setup the car with some defaults tires & springs 
for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) 
{ 
  %obj.setWheelTire(%i,%obj.tyreType); 
  %obj.setWheelSpring(%i,%obj.springType); 
} 
}

That should load in your custom tires and springs.
#2
03/04/2002 (8:01 pm)
I'm not sure if that will work, I'll try it though, there are datablock's for the tire and springs

datablock WheeledVehicleTire(DefaultCarTire)
datablock WheeledVehicleSpring(DefaultCarSpring)

Changing it to:
datablock WheeledVehicleTire(TestCarTire)
datablock WheeledVehicleSpring(TestCarSpring)

then using them it on add

function WheeledVehicleData::onAdd(%this,%obj) 
{ 
// Setup the car with some defaults tires & springs 
for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) { 
%obj.setWheelTire(%i,TestCarTire); 
%obj.setWheelSpring(%i,TestCarSpring); 
} 
}

Should work I would think... but it doesn't
#3
03/04/2002 (8:50 pm)
Oh :/

That scripting is correct so if that dosnt work, you may have to look at the engine vehicle code.
#4
04/18/2002 (5:29 pm)
I know this is old but I'll put it here for those looking to put it into their game..

function WheeledVehicleData::onAdd(%this,%obj)
{
   %veh = %obj.getDatablock();
   for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--)
   {
      %obj.setWheelTire(%i,%veh.tireType);
      %obj.setWheelSpring(%i,%veh.springType);
   }
}
You have to make the datablock call or the wheels wont mount. %obj is calling the ID and %veh is calling the datablock.
#5
04/18/2002 (6:12 pm)
It's pretty easy to get your tires how you want them. This is for my 'excalibur' car:
datablock WheeledVehicleTire(ExcaliburTire)
{
   // note 'ExcaliburTire' above
   // default comments above here ...
   shapeFile = "~/data/shapes/excalibur/excalibur_tire.dts";
   // the other default code below ...
};

datablock WheeledVehicleSpring(ExcaliburSpring)
{
   // The defaults here.  Note 'Excalibur Spring' above
};

function WheeledVehicleData::onAdd(%this,%obj)
{
   // Setup the car with tires & springs
   for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) {
      %obj.setWheelTire(%i,ExcaliburTire);
      %obj.setWheelSpring(%i,ExcaliburSpring);
   }
}
Notice above the ExcaliburTire and ExcaliburSpring for onAdd. This works for the Excalibur car ... I haven't tried adding more than one car, yet. So you may have to use the other onAdd routine posted ...

- rjp
#6
04/18/2002 (6:32 pm)
I do have a question though... Where is the center of the tire in Max? I dont see a node or dummy defining the center, and the tire that I have sits in the air and doesnt make contact with the ground.
#7
04/18/2002 (6:40 pm)
it is the pivot point of the bounding box for the shape
#8
09/24/2002 (5:56 am)
Does anyone know a solution to this?

-- Adrian St. Onge
#9
09/26/2002 (4:33 pm)
Oops... I forgot about this post, I probably should have posted my solution. The problem was a naming problem, only not with the dataBlock itself.

function WheeledVehicleData::onAdd(%this,%obj)

adds the same tires to every WheeledVehicleData dataBlock, so you just need to change it to something like

function DefaultCar::onAdd(%this,%obj)

where DefaultCar is the name of your vehicle's dataBlock.
#10
09/27/2002 (4:06 am)
Yeah.. After staring at the script code, I kinda noticed that.

-- Adrian St. Onge
#11
10/09/2002 (12:36 pm)
Great Thanks for bumping this thread up because I was having the same problem.