Multiple Vehicle Wheel problems
by Ronald J Nelson · in Torque Game Engine · 10/25/2005 (10:46 am) · 11 replies
I know I am probably missing something obvious but when I tried to add new vehicles to the race game they all have the same wheels that are on the buggy. What am I doing wrong?
#2
as far as I can tell I did everything right.
10/25/2005 (4:53 pm)
Nope.datablock WheeledVehicleTire(BuggyTire)
{
// Tires act as springs and generate lateral and longitudinal
// forces to move the vehicle. These distortion/spring forces
// are what convert wheel angular velocity into forces that
// act on the rigid body.
shapeFile = "~/data/shapes/Buggy/wheel.dts";
//
//
datablock WheeledVehicleTire(Redcar)
{
// Tires act as springs and generate lateral and longitudinal
// forces to move the vehicle. These distortion/spring forces
// are what convert wheel angular velocity into forces that
// act on the rigid body.
shapeFile = "~/data/shapes/redcar/wheel.dts";as far as I can tell I did everything right.
#3
10/25/2005 (5:16 pm)
Make sure you are using the Redcar datablock when you are creating your redcar model, and you aren't accidentally attaching the BuggyTire to the car instead of your new one.
#4
Whatever car I select is the car whose wheels are showing up. The body is the same as it should be, but not the wheels.
10/25/2005 (5:52 pm)
OK now I see thee is a difference when I chose a different car to spawn mounted in. I use a variable that gets transfered with the client data.function GameConnection::spawnPlayer(%this)
{
// Combination create player and drop him somewhere
%spawnPoint = pickSpawnPoint();
%this.createvehicle(%spawnPoint);
}
function GameConnection::createvehicle(%this, %spawnPoint)
{
error("inside onNewDataBlock");
if (%this.vehicle > 0)
{
// The client should not have a player currently
// assigned. Assigning a new one could result in
// a player ghost.
error( "Attempting to create an angus ghost!" );
}
%player = new Player()
{
dataBlock = PlayerBody;
client = %this;
};
error("created player");
MissionCleanup.add(%player);
error("added driver to missionCleanup");
// player setup
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
%this.camera.setTransform(%player.getEyeTransform());
%this.player = %player;
//%this.setControlObject(%player);
// Starting equipment
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,10);
%player.mountImage(CrossbowImage,0);
// Create the vehicle object
%vehicle = new WheeledVehicle()
{
dataBlock = %this.clientVehicle;
mountable = true;
client = %this;
};
error("created vehicle");
MissionCleanup.add(%vehicle);
error("added vehicle to missionCleanup");
//attempt to mount player
error("Attempting to mount player to vehicle");
%node = "mount0";
//%this.player.onMount(%this,%player,%vehicle,%node);
%vehicle.mountObject(%player, 0);
//%player.Armor.onMount(%this,%player,%vehicle,%node);
// Player setup...
%vehicle.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
// Update the camera to start with the player
%this.camera.setTransform(%vehicle.getEyeTransform());
// Give the client control of the player
%this.vehicle = %vehicle;
%this.setControlObject(%vehicle);
error("leaving racing.game.cs");
}Whatever car I select is the car whose wheels are showing up. The body is the same as it should be, but not the wheels.
#5
I guess what I need to know is if there is someway to reconstruct the car datablock so that everything (wheels, springs, emitters,..) is contained within the one datablock.
10/25/2005 (8:13 pm)
I may be mistaken but I believe it is because the wheels are not being sent with the vehicle data block. Has anyone dealt with this before and had a solution?I guess what I need to know is if there is someway to reconstruct the car datablock so that everything (wheels, springs, emitters,..) is contained within the one datablock.
#6
Let me add some more details. My player spawns with a vehicle of his chosing that he can exit and enter into any other vehicle that is available. The cars bodies are loading just fine. However, anything that is not within the vehicles primary datablock is being set to what ever the individual client had slected for their vehicle.
Help!!
10/25/2005 (9:42 pm)
OK my problem lies within my function WheeledVehicleData::onAdd(%this,%obj). It needs to be able to load the correct wheels, springs, or anything else I add on to it based upon the vehicle that the player has chosen.Let me add some more details. My player spawns with a vehicle of his chosing that he can exit and enter into any other vehicle that is available. The cars bodies are loading just fine. However, anything that is not within the vehicles primary datablock is being set to what ever the individual client had slected for their vehicle.
Help!!
#7
First I created a vehicle.cs file to keep functions universal to all vehicles and added:
10/25/2005 (11:42 pm)
OK I came up with a solution that works very well. It also allows lots of other customizations.First I created a vehicle.cs file to keep functions universal to all vehicles and added:
function WheeledVehicleData::onAdd(%this,%obj)
{
// Setup the car with custom tires & springs
%obj.setWheelTire(0,%this.RFTire);
%obj.setWheelTire(1,%this.LFTire);
%obj.setWheelTire(2,%this.RRTire);
%obj.setWheelTire(3,%this.LRTire);
%obj.setWheelSpring(0,%this.Spring);
%obj.setWheelSpring(1,%this.Spring);
%obj.setWheelSpring(2,%this.Spring);
%obj.setWheelSpring(3,%this.Spring);
%obj.setWheelPowered(0,false);
%obj.setWheelPowered(1,false);
// Steer front tires
%obj.setEngine(CarEngine);
%obj.setWheelSteering(0,1);
%obj.setWheelSteering(1,1);
// Only power the two rear wheels...
%obj.setWheelPowered(2,true);
%obj.setWheelPowered(3,true);
}
#8
10/25/2005 (11:46 pm)
Then in each of the vehicle's *.cs files I did this:datablock WheeledVehicleTire(CarRFTire)
{
// Tires act as springs and generate lateral and longitudinal
// forces to move the vehicle. These distortion/spring forces
// are what convert wheel angular velocity into forces that
// act on the rigid body.
shapeFile = "~/data/shapes/car/wheel.dts";
staticFriction = 4;
kineticFriction = 3;
// Spring that generates lateral tire forces
lateralForce = 18000;
lateralDamping = 4000;
lateralRelaxation = 1;
// Spring that generates longitudinal tire forces
longitudinalForce = 18000;
longitudinalDamping = 4000;
longitudinalRelaxation = 1;
};
datablock WheeledVehicleTire(CarLFTire)
{
// Tires act as springs and generate lateral and longitudinal
// forces to move the vehicle. These distortion/spring forces
// are what convert wheel angular velocity into forces that
// act on the rigid body.
shapeFile = "~/data/shapes/car/wheel.dts";
staticFriction = 4;
kineticFriction = 3;
// Spring that generates lateral tire forces
lateralForce = 18000;
lateralDamping = 4000;
lateralRelaxation = 1;
// Spring that generates longitudinal tire forces
longitudinalForce = 18000;
longitudinalDamping = 4000;
longitudinalRelaxation = 1;
};
datablock WheeledVehicleTire(CarRRTire)
{
// Tires act as springs and generate lateral and longitudinal
// forces to move the vehicle. These distortion/spring forces
// are what convert wheel angular velocity into forces that
// act on the rigid body.
shapeFile = "~/data/shapes/car/wheel.dts";
staticFriction = 4;
kineticFriction = 3;
// Spring that generates lateral tire forces
lateralForce = 18000;
lateralDamping = 4000;
lateralRelaxation = 1;
// Spring that generates longitudinal tire forces
longitudinalForce = 18000;
longitudinalDamping = 4000;
longitudinalRelaxation = 1;
};
datablock WheeledVehicleTire(CarLRTire)
{
// Tires act as springs and generate lateral and longitudinal
// forces to move the vehicle. These distortion/spring forces
// are what convert wheel angular velocity into forces that
// act on the rigid body.
shapeFile = "~/data/shapes/car/wheel.dts";
staticFriction = 4;
kineticFriction = 3;
// Spring that generates lateral tire forces
lateralForce = 18000;
lateralDamping = 4000;
lateralRelaxation = 1;
// Spring that generates longitudinal tire forces
longitudinalForce = 18000;
longitudinalDamping = 4000;
longitudinalRelaxation = 1;
};
datablock WheeledVehicleSpring(CarSpring)
{
// Wheel suspension properties
length = 0.73; // Suspension travel
force = 3000; // Spring force
damping = 600; // Spring damping
antiSwayForce = 3; // Lateral anti-sway force
};
datablock WheeledVehicleEngine(CarEngine) {
// Default Engine info...
MinRPM = 500.0;
MaxRPM = 4500.0;
throttleIdle = 0.1;
numGears = 5;
gearRatios[0] = 3.78;
gearRatios[1] = 2.06;
gearRatios[2] = 1.35;
gearRatios[3] = 0.97;
gearRatios[4] = 0.74;
diffRatio = 3.39;
reverseRatio = 3.60;
shiftUpRPM = 2300.0;
shiftDownRPM = 1100.0;
numTorqueLevels = 8;
rpmValues[0] = 500.0;
torqueLevel[0] = 70.0;
rpmValues[1] = 1000.0;
torqueLevel[1] = 100.0;
rpmValues[2] = 1500.0;
torqueLevel[2] = 130.0;
rpmValues[3] = 2000.0;
torqueLevel[3] = 150.0;
rpmValues[4] = 2500.0;
torqueLevel[4] = 140.0;
rpmValues[5] = 3000.0;
torqueLevel[5] = 125.0;
rpmValues[6] = 3500.0;
torqueLevel[6] = 120.0;
rpmValues[7] = 4000.0;
torqueLevel[7] = 105.0;
rpmValues[8] = 4500.0;
torqueLevel[8] = 60.0;
};
#9
Remember to change the part like CarSpring and the "Car" labelled wheel datablocks to names for each of your vehicles.
Finally, add this to the bottom of your vehicle's main datablock. Again remember to change the "Car" references for each of your vehicles.
10/25/2005 (11:48 pm)
That replaced the spring info and wheel info, oh yeah and I am trying to get a working transmission. heheh.Remember to change the part like CarSpring and the "Car" labelled wheel datablocks to names for each of your vehicles.
Finally, add this to the bottom of your vehicle's main datablock. Again remember to change the "Car" references for each of your vehicles.
RFTire = "CarRFTire"; LFTire = "CarLFTire"; RRTire = "CarRRTire"; LRTire = "CarLRTire"; Spring = "CarSpring";
#10
10/25/2005 (11:49 pm)
Oh and don't forget to make that vehicle.cs file or what ever you use executed at the game.cs file.
#11
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.
05/19/2006 (9:04 pm)
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.
Torque Owner Dave D