Vehicle mods
by Howard Dortch · in Torque Game Engine · 04/28/2007 (7:43 am) · 3 replies
I would like to change a value on the vehicle and have it on a per vehicle basis but having some problems. Each vehicle can have a different top speed, mass etc and have the values change from script within the game due to some action. For instance one truck has a load of rocks and one is empty so different mass.
I added the variables in C++ to the .h file set as protected then wrote functions to alter the values and called those functions from script. In debug I can see the changes take place but during the call to updateForces I set a breakpoint and the value is the same value I set in the constructor, no changes to max speed or mass etc. Anyone point me in the right direction?
I added the variables in C++ to the .h file set as protected then wrote functions to alter the values and called those functions from script. In debug I can see the changes take place but during the call to updateForces I set a breakpoint and the value is the same value I set in the constructor, no changes to max speed or mass etc. Anyone point me in the right direction?
#2
When the game runs, the constructor for the vehicle is called 3 times before I hit the main menu I will assume that some engine setup.
When I start the game by loading the mission the constructor for the vehicle gets hit and the onAdd method is called and all my data is set properly.
During the load process the constructor is hit again and I will assume it's the ghost object but the onAdd method is not called this time.
I set a break point in update forces to hit when I apply the throttle key and the update "this" references the last object. Not the object that called the onAdd function but the one after that.
So that is why the data fails to work.
The constructor gets hit 5 times to produce one vehicle.
The only time the onAdd function is called is the 4th one in the list.
The engine does updates on the last one in the list.
I dont understand all the calls to the constructor so could someone help here?
04/29/2007 (8:58 am)
I have all that in and working but I think I see the problem.When the game runs, the constructor for the vehicle is called 3 times before I hit the main menu I will assume that some engine setup.
When I start the game by loading the mission the constructor for the vehicle gets hit and the onAdd method is called and all my data is set properly.
During the load process the constructor is hit again and I will assume it's the ghost object but the onAdd method is not called this time.
I set a break point in update forces to hit when I apply the throttle key and the update "this" references the last object. Not the object that called the onAdd function but the one after that.
So that is why the data fails to work.
The constructor gets hit 5 times to produce one vehicle.
The only time the onAdd function is called is the 4th one in the list.
The engine does updates on the last one in the list.
I dont understand all the calls to the constructor so could someone help here?
#3
04/30/2007 (7:53 am)
I changed things to use stream reads and writes and that seems to solve the problem. Now if I can get the vehicles to move smothe instead of jerking around ....
Torque Owner Jacobin
You need to add your variable to the public class section. Look for other instanced variables such as mBrakesApplied as a clue you're in the correct area.
You'll need to write a console function to expose the variables to script. You'll need to change relevant functions to use the new variables as opposed to the depreciated ones. If you only are going to be accessing the values in server side scripts, I think you can probably get away without adding them to pack/unpack.