Game Development Community

Bug Found: Loading wrong tires for different vehicles

by Eric Smith · in Torque Game Engine Advanced · 04/20/2009 (12:47 pm) · 5 replies

I hear mention of sometimes wrong tires loading from other vehicles. I've tracked down HOW it happens but I don't know a fix.

In game.cs, whatever vehicle is loaded last, that is the tires other vehicles will sometimes use.

EDIT: I'm using TGEA 1.8.1

exec("./car.cs");
   exec("./equipment/tractor.cs");

buggy will use the tractors tires.

exec("./equipment/tractor.cs");
   exec("./car.cs");

tractor will use the buggy tires.

The WheeledVehicleTire() datablocks are completely different names.

Buggy:
datablock WheeledVehicleTire(DefaultCarTire)

Tractor:
datablock WheeledVehicleTire(TractorTire1)
datablock WheeledVehicleTire(TractorTire2)

#1
04/20/2009 (2:50 pm)
Are you setting the correct tire with setwheeltire when the vehicle is added? (usually in the onAdd method for the type of vehicle)

I'm not sure what could be causing this. (I'll try to dig around it later if I have some time)

Edit: I've reread your post and I assume my guess won't help since it is using the right tires some of the time.

Interesting problem that I haven't experienced myself, I'll try to recreate it.
#2
04/21/2009 (11:53 am)
Yea with my second vehicle, Ive confirmed it. Happens 100% of the time. Now my new vehicle has the tires of my other vehicle when I load it after it. I know the tire, spring and vehicle datablock names are defiantly not the same.
#3
04/21/2009 (4:18 pm)
I figured it out. From a post by Kevin Ostrowski:

Quote:
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.

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

I think for the sake of this issue, the car.cs should be corrected in the distribution.

Issue closed.
#4
04/21/2009 (4:43 pm)
Quote:I think for the sake of this issue, the car.cs should be corrected in the distribution.
Actually, the car.cs is quite correct as an example. To make it properly reflect multiple vehicles is as simple as adding a tireType/springType field(s) to the vehicle datablock and changing the onAdd() callback to look for the correct type for the datablock in question. One of the purposes of class Namespace functions is to reduce (or prevent) code duplication, of which your suggestion would require an additional onAdd() for each individual vehicle.

But your solution will work, I'm not knocking that, I'm just a lazy coder. I have multiple vehicles(6 types) with differing wheels(4 types) and springs(3 types) but only one onAdd() callback that handles them all.
#5
04/21/2009 (4:56 pm)
Ok. I only suggested that for the sake of confusion since it confused me. :) I have multiple vehicles. All with different tires and different steering and power distributions.