Vehicle Study.

Until this forum becomes busy just include BF2, 2142 or BFV in the title

Vehicle Study.

Postby Archimonday » Sun Jan 23, 2011 3:07 am

Sorry I havn't posted any new Youtube videos in awhile. I've been working with some mod teams on BF2 stuff. Just wanted to share this, I did a study of vehicle code recently using the editor to find out what everything did. It should be useful to some people.

Battlefield 2 Vehicle Study
Engine Coding - Physics Modification


ObjectTemplate.Drag - Adds Wind Resistance.
When raised, will give the vehicle lowered acceleration properties, affected by physics rather than engine parameters. For Airplanes, drag can be used to aid in the illusion of stalling, and other low represented physical properties.

ObjectTemplate.Mass - Weight of the Vehicle
Mass has no specific value for weight, which means, in theory, you could pick any measurement of weight you chose. Basically, if you wanted your modification to use pounds instead of kilograms, you would have to set the mass of every vehicle in the mod to a measurement in pounds rather than kilograms.
However, in testing, It seems that Metric measurements work far better with the BF2 engine.
The weight of the vehicle has no direct effect on the ability of an engine to move the vehicle. The mass of the vehicles determines which vehicles are heavier than others, and thus which vehicles can move others by ramming into them. So for instance, a T-90, being lighter than the M1 Abrams, would most likely be pushed around by the Abrams in Battlefield 2.

ObjectTemplate.InertiaModifier - Modifys the effects of in-game physics on the 3 axi's of rotation.
Example: If I raise the X factor on the Inertia Modifier to a higher number, say 5, the Intertia put on that vehicle on the X axis, or as in turning, is much greater, which makes the vehicle turn much harder. An intertia Modifier on the Z axis effects the vehicles speed both in forward and reverse in a straight line. A Y axis intertia modifier would effect the vehicle in vertical movement, say in an airplane, it would climb slower.

ObjectTemplate.GravityModifier - Modifys vehicles gravitational pull
A higher gravity modifier will make a vehicle fall faster, one below zero or negative may even make it float.

---- Engines ----
NewCar2 - NewCar2 is Dices new Car Engine modifier which when engine type is specified as NewCar2, gives players alot of variables to affect the acceleration, gearing, and overall performance of a vehicle. If a vehicles engine type is not NewCar2 these values are void and are not used.

Engine Physics - Physics on an engine do not matter, Mass is pointless because it will never contact any other object in-game. Gravity, Inertia, Drag, and these other settings are all defined in the vehicles default notary, so there is no need to use these in the Engine settings.

Torque - The amount of Torque.
Torque in Bf2 could also be called "power". Just as in Mass, there is no definition for how torque is calculated, whether it be in Ft/Ibs, or Nm's, or another measurement. So in theory one could use any measurement one wanted, as long as it was kept universal around all the objects in the game.

To calculate a realistic torque of a vehicle, one can use its Engine Horsepower, its Rotations Per Minute, and some simple math involving circles to calculate a standard engine power output.
For Instance:

The slowest of the T-90 Main Battle Tanks have an 840 Horsepower engine that we'll say runs at 3000 rpm. To calculate for the T-90's amount of torque, which will enable it to climb steep slopes, and cross over rough terrain easier, and eventually reach 60 mph, we can calculate the torque:

T = HP (33,000)
2pi (RPM)

HP = Horsepower
RPM = rotations per minute
T = Torque

T = 840 (33,000)
6.28318 ( 3000 )
T = 2772000 / 18849.54
T = 1208.093

We now have the engine out put for these specifications on this vehicle. This will give the T-90 a lot of power output.

Differential - Differential is how much of the Torque, we just calculated, actually gets transfered to the wheels of the vehicle, determining its speed.
The Differential on a vehicle should be decided by the modder to match what goals he/she is trying to accomplish. With this torque, our T-90 will climb hills, and drive relatively fast for a vehicle of this type, but it will also accelerate very quickly. We've already determined a way to lower the acceleration of the vehicle, but Drag, in addition to slowing the acceleration, can also affect the vehicles top speed.
I set the Differential of this T-90 to its defaulted 12, because I liked the amount of power transfer that was there, and its top speed was good to me.
Number Of Gears - Number of Gears for the Transmission.
BF2 has a strange affair with vehicles that use more than a single gear in their transmission. One will find that when using more than a single gear in a transmission that a vehicle in BF2 is liable to become stuck on hills. This is because the game decides when the vehicle shifts, instead of the player. As a result, the player will remain stuck between two gears when climbing a steep slope, unless the vehicle has sufficient torque to climb the slope, and keeps it RPM's steady without dropping below the GearDown percentage, or going above the GearUp percentage.
When an engine shifts to a new gear, it is switching to a new gear to ease strain on the engine, and allow it to rotate more freely, or to engage more power depending on the situation.
Battlefield 2 however is not very precise in its measurements of gears, therefore, often times vehicles will go from first to second gear very quickly, not an uncommon thing in most vehicles, however when it enters second gear the vehicle will magically gain a burst of energy, which can be noticed as the vehicles front end goes upward, and then drops back down. Its as if the vehicle if fired into its top speed in second gear, rather than 3rd, 4th, or even higher, especially in the case of our T-90 which has a 7 forward transmission.
BF2 also limits the number of gears you can put on a vehicle. Five is the maximum. When you are defining gearRatios for a 5 speed transmission in BF2, the final number will act as the reverse, and the previous four will be taken as the forward gears. So in reality, BF2 only allows for a 4 forward, 1 reverse transmission on all vehicles.
In this particular case, I chose to leave the T-90 has a single forward gear. If I had set the gears to 5 for this T-90, the gear ratios of this tanks transmission were unknown to me, so in order to find a ratio on first gear that would even allow the tank to move in the first place, was very high. With a single gear, I am also able to adjust the acceleration of the tank far more accurately than if I was using multiple gears.
Engine Rotation -
MinRotation - Set for an engines minimum speed. All of these values are represented by the X Y and Z Axis of movement.
X - being left and right
Y- being up and down
Z - being forward and back.
For a tank or a vehicle, MinRotation should be set to -1, so the vehicle remains idle, and doesn't move when the engine is started. -1 is usually used to identify inifinity with the Refractor 2 engine.
MaxRotation - MaxRotation and MinRotation should not be used for Tanks, as they are primarily used for Dummy Engines. Setting a MaxRotation on a physics engine, will cause the engine to reach that top speed, but upon stopping, maintain that rotation, disabling the vehicle.
MaxSpeed - MaxSpeed like most of these values is decided by a percentage value where 100 percent is represented by 1. If I set the X value to a number lower than one, say 0.6. The engine will only use 60 percent of its power when turning. If I set the number on the Z to 1, it will use 100 percent of its power while accelerating forward.

Acceleration - I can now set the Acceleration for each Axis. X, Y, and Z. If I want my vehicle to accelerate slower on the Z, I can modify the Z value of the Acceleration to do that. If I want it reach its maximum turning RPM quickly, I can modify the X value to do this.
Acceleration is calculated in percentage with 100 percent being represented by 1. so if I want my vehicle to accelerate to full speed at a rate of 15 percent power, I could put 0.15 in as my Z value. If I wanted my vehicle to accelerate in a turn almost instantly, a value of 1, or slightly below would be necessary.

DeAcceleration - DeAcceleration works identically to Acceleration, with a percentage value represented by 1.
enabling DeAcceleration with ObjectTemplate.UseDeAcceleration will enable these values.
Setting a lower than 1 percentage value on the X axis will mean the vehicle will continue to turn after input was released.
Setting a lower than 1 percentage on the Z will mean a vehicle will continue to moved forward after input is released.
For helicopters and aircraft a lower than 1 percentage on the Y will mean the vehicle will climb after input is released.
I dont recommend using it.

ContinuosRotationSpeed - Does not work with land vehicles, much like Min and Max Rotation.
AutomaticReset - AutomaticReset will tell the game that everytime the player releases the input keys, that the engine should return to its default state, with no power. Depending on the settings you have placed in your vehicle, the time it takes to slow down from high speed can vary. Alternatively, you can turn AutomaticReset off, and have acceleration similar to that of Red Orchestra, where the player can incrementally increase his/her speed, and in the same way decrease it.
The only problem with having it disabled is that it does this for turns as well, and sometimes it can be very hard for specific settings on a vehicle to get it to stop properly, often times you'll kick it into reverse quite by accident. You can increase the gear change time to try and counteract that, but AutomaticReset makes in much more user friendly controls.

SnapToZeroOnNoInput - This code is very useful for tanks, and for physics engines. Setting it to true, or 1 in this case, means that as soon as the player lets go of the throttle on his/her vehicle, the engine resets itself. It makes for much shorter stops, and easier transition between forward and reverse.
LesserYawAtSpeed - Useful code that works with a percentage value represented by 1. Setting this to 0.8, means at 80 percent speed, the vehicle will be harder to turn, than lower than 0.8.

These explain all of the primary values you'll need to modify land vehicle engines to your hearts content.
Posts: 42
Joined: Tue Oct 27, 2009 2:11 am

Re: Vehicle Study.

Postby fo0k » Sun Jan 23, 2011 5:34 pm

Very interesting indeed! Thanks, I'll be back to look at this thread for sure.
User avatar
Posts: 1416
Joined: Fri Oct 16, 2009 4:21 pm
Location: UK

Return to Battlefield 2, 2142 and Vietnam Discussion

Who is online

Users browsing this forum: No registered users and 2 guests