Game Development Community

Speed boost/turbo

by CodingChris · in Torque Game Engine Advanced · 01/07/2008 (5:54 am) · 8 replies

Hi,
Does someone know how to do a speed booster/turbo for vehicles in TGEA?

#1
01/08/2008 (11:31 am)
Add a force to updateForces when your new turbo state is set. It would depend on whether it is supposed to be a force from the engine acting through the wheels, or more like a JATO rocket.

For the JATO type, you can implement the force to decrease as the speed gets higher, (similar to how the engine power is implemented in the stock Torque) in order to impose a particular maximum speed.
#2
01/08/2008 (11:47 am)
See mJetting in the WheeledVehicle: this is the "engine" type turbo. It is already implemented and it doubles the engine torque when set (but the same maximum speed is still retained through the maxWheelSpeed field. You might add a boost to the effective maxWheelSpeed in addition to the torque doubling if desired.)

Note that if you are flying through the air after jumping, getting the force in through the engine and wheels won't do anything much.

In the FlyingVehicle, mJetting adds additional force (forward or backward per the current command).
#3
01/09/2008 (3:49 am)
Sorry, but I don't understand you. Do I have to look in source code for this?
#4
01/09/2008 (3:19 pm)
That would be the easiest way to see exactly what the settings do. For example, I believe that the mJetting boolean in the code gets turned on by trigger 3.

If you hook some key to trigger 3.... watch out! :)

(I haven't tried it to see if it still works, but at first glance it looked like it was still hooked up.)
You might need to set a car datablock jetForce field with a large force to test it. (Set it to 10 or 20 times the mass to get an extra 1 gravity of acceleration. The stock buggy has a mass of 400 so I'd try 4000 to start off. )

edit:
I was glanced at your plan and the recent comments. The existing code even has the Jetting hooked into the obsolete Tribes "Energy" system. Reusing that stuff would give you the "run out of juice feature" also...
Jetting also uses jetEnergyDrain, minJetEnergy, ...

Only way to find all the cool features hidden away is to look at the code occasionally.
#5
01/10/2008 (5:39 am)
Now I added this:
Car datablock:
// Energy
    jetForce = 30000;
    minJetEnergy = 30;
    maxEnergy = 800;
    jetEnergyDrain = 200;
    rechargeRate = 0.8;

 // Rigid Body
     mass = 360;
   
   massCenter = "0 -0.3 0";    // Center of mass for rigid body
   massBox = "0 0 0";         // Size of box used for moment of inertia,
                              // if zero it defaults to object bounding box
and this:
moveMap.bind( mouse, button1, mouseTurbo );

function mouseTurbo(%val)
{
   $mvTriggerCount3++;
}
but this changes nothing. So, could you please tell me what I'm doing wrong and what does out of juice mean? Sorry, but I'm German.
#6
01/10/2008 (1:07 pm)
Similar changes work for me.
I would set the jetEnergyDrain = 0; until you are sure the added force is working. (If you do not, you might run out of energy and the extra effect might go away.)

The code doubles the engine torque when jetting so the drive wheels might spin.
It doesn't act as I would expect if you try jetting while stopped. You might get started moving with the engine then add the jetting.

(There are states in the wheeled vehicle code that can freeze motion when stopped. I would have to look into it in detail to see what it is doing. Or it could be some issue with my modifications, so you might not see this effect at all.)

Good luck
#7
01/10/2008 (1:14 pm)
I set jetEnergyDrain to 0 but it still doesn't work.
#8
02/16/2008 (8:02 am)
Make sure your maxwheelspeed is not already being reached.