Vehicle selction datablocks
by Jim \"Night\" Lee · in Torque Game Engine · 08/29/2006 (10:26 pm) · 5 replies
Well i have a vehicle selection code that selects the datablock of the car to be used. So my question is that when the car is selected only the body changes not the wheel and spring data meaning all the vehicles will have the same wheels and spring data. So is there a way to make the wheel and spring force datablock to also load and change. Or more like load seperate cs files instead of just datablocks for vehicles. I tried many things though but i new to programming so this is kind of hard but i feel i may be overlooking something. If you can help please do.
#2
08/30/2006 (9:44 pm)
I did something very simular to this but I'll try it anyway tomorrow cause it to late here.
#3
I tried putting it in if functions:
it now only uses the default car wheels instead of using the humvee wheels before
09/05/2006 (6:52 pm)
Hmm it doesnt work as i thought maybe i am doing it wrong?I tried putting it in if functions:
if(%auto == "DefaultCar")
{
for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) {
%obj.setWheelTire(%i,DefaultCarTire);
%obj.setWheelSpring(%i,DefaultCarSpring);
%obj.setWheelPowered(%i,false);
}
} else if(%auto == "humvee") {
for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) {
%obj.setWheelTire(%i,humveeTire);
%obj.setWheelSpring(%i,humveeSpring);
%obj.setWheelPowered(%i,false);
}
}it now only uses the default car wheels instead of using the humvee wheels before
#4
09/06/2006 (3:52 am)
Can you post the whole function? Wanna see where you getting %auto from.
#5
but there is more but that is in GUIs that call it
and in game.cs:
09/06/2006 (6:30 pm)
Here its is in clientConnection:but there is more but that is in GUIs that call it
function GameConnection::onConnect( %client, %name, %auto )
{
if(%auto !$= "")
{
%client.auto = %auto;
}
else
{
%client.auto = "DefaultCar";
}and in game.cs:
// Create the player object
%car = new WheeledVehicle() {
dataBlock = %this.auto;
client = %this;
};
Torque Owner James Laker (BurNinG)
Make sure you have this defined and setup somewhere:
And also :
Then in your onAdd function look and change the variables passed to setWheelTire and setWheelSpring:
to something like this
I'm doing this blindly, so this probably won't be 100% correct, but it gives you an idea.