Getting custom wheels working on a vehicle
by BigDaz · in Torque 3D Beginner · 12/31/2012 (10:10 am) · 23 replies
I'm stuck getting the correct wheel to appear on my vehicle.
Essentially what I've done is copy the cheetah datablocks and script and simply changed the values to suit my new vehicle. But no matter what I try the DefualtCarTire always overrides it and it ends up with buggy wheels.
Up until now I've worked around it by going into scripts/server/vehicleWheeled.cs
and changing DefaultCarTire to point to my car tire instead. This works but I'm creating a tutorial at the moment so I'd like to know the proper way. I'm puzzled why the Cheetah works but mine doesn't.
Datablock:
Car Script:
Essentially what I've done is copy the cheetah datablocks and script and simply changed the values to suit my new vehicle. But no matter what I try the DefualtCarTire always overrides it and it ends up with buggy wheels.
Up until now I've worked around it by going into scripts/server/vehicleWheeled.cs
// Setup the car with some tires & springs
for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--)
{
%obj.setWheelTire(%i, DefaultCarTire);
%obj.setWheelSpring(%i, DefaultCarSpring);
%obj.setWheelPowered(%i, false);
}and changing DefaultCarTire to point to my car tire instead. This works but I'm creating a tutorial at the moment so I'd like to know the proper way. I'm puzzled why the Cheetah works but mine doesn't.
Datablock:
datablock WheeledVehicleTire(CarTire)
{
// 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 = "art/shapes/Car/Wheel.dae";
staticFriction = 4.2;
kineticFriction = "1";
// Spring that generates lateral tire forces
lateralForce = 18000;
lateralDamping = 6000;
lateralRelaxation = 1;
// Spring that generates longitudinal tire forces
longitudinalForce = 18000;
longitudinalDamping = 4000;
longitudinalRelaxation = 1;
radius = "0.609998";
};
datablock WheeledVehicleSpring(CarSpring)
{
// Wheel suspension properties
length = 1.5; // Suspension travel
force = 2800; // was 2800 // Spring force
damping = 3600; // Spring damping
antiSwayForce = 3; // Lateral anti-sway force
};
datablock WheeledVehicleData(Car)
{
category = "Vehicles";
shapeFile = "art/shapes/Car/Car.DAE";
emap = 1;
mountPose[0] = sitting;
numMountPoints = 1;
useEyePoint = false; // Use the vehicle's camera node rather than the player's
maxSteeringAngle = 0.585; // Maximum steering angle, should match animation
// 3rd person camera settings
cameraRoll = false; // Roll the camera with the vehicle
cameraMaxDist = 20; // Far distance from vehicle
cameraOffset = 3.0; // Vertical offset from camera mount point
cameraLag = "0.3"; // Velocity lag of camera
cameraDecay = 1.25; // Decay per sec. rate of velocity lag
// Rigid Body
mass = "400";
massCenter = "0 0.5 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
drag = 0.6; // Drag coefficient
bodyFriction = 0.6;
bodyRestitution = 0.4;
minImpactSpeed = 5; // Impacts over this invoke the script callback
softImpactSpeed = 5; // Play SoftImpact Sound
hardImpactSpeed = 15; // Play HardImpact Sound
integration = 8; // Physics integration: TickSec/Rate
collisionTol = "0.1"; // Collision distance tolerance
contactTol = "0.4"; // Contact velocity tolerance
// Engine
engineTorque = 4300; // Engine power
engineBrake = "5000"; // Braking when throttle is 0
brakeTorque = "10000"; // When brakes are applied
maxWheelSpeed = 50; // Engine scale by current speed / max speed
// Energy
maxEnergy = 100;
jetForce = 3000;
minJetEnergy = 30;
jetEnergyDrain = 2;
// Sounds
engineSound = cheetahEngine;
//squealSound = cheetahSqueal;
softImpactSound = softImpact;
hardImpactSound = hardImpact;
// Dynamic fields accessed via script
nameTag = 'Car';
maxDismountSpeed = 10;
maxMountSpeed = 5;
mountPose0 = "sitting";
tireEmitter = "CarTireEmitter";
dustEmitter = "CarTireEmitter";
dustHeight = "1";
};Car Script:
function Car::onAdd(%this, %obj)
{
Parent::onAdd(%this, %obj);
%obj.setWheelTire(0,CarTire);
%obj.setWheelTire(1,CarTire);
%obj.setWheelTire(2,CarTire);
%obj.setWheelTire(3,CarTire);
// Setup the car with some tires & springs
for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--)
{
%obj.setWheelPowered(%i, true);
%obj.setWheelSpring(%i, CarSpring);
}
// Steer with the front tires
%obj.setWheelSteering(0, 1);
%obj.setWheelSteering(1, 1);
}
function Car::onRemove(%this, %obj)
{
Parent::onRemove(%this, %obj);
}About the author
#2
Thanks to the other thread I posted, I got some great info. I've since been working on a new Vehicle to actually learn the process fully.
I think I'm likely to get a speed bump when I reach the point that I add mounting nodes since that's not very clear to me. I will see how it goes.
I just want to call first DIBs on your Tutorial !
Thank you BigDaz.
12/31/2012 (10:51 am)
@BigDazThanks to the other thread I posted, I got some great info. I've since been working on a new Vehicle to actually learn the process fully.
I think I'm likely to get a speed bump when I reach the point that I add mounting nodes since that's not very clear to me. I will see how it goes.
I just want to call first DIBs on your Tutorial !
Thank you BigDaz.
#4
12/31/2012 (12:55 pm)
Do the wheels mount ok, in the Shape Editor?
#5
Change 1 line in the datablock
And change 1 line in the script file
Then I get a Cheetah using the default buggy wheels. Which I don't get as everything else is identical. I thought it might be a problem with having two declarations but even if I remove the original Cheetah from the game, this new copy comes up wrong. Can anyone else replicate this?
12/31/2012 (1:15 pm)
If I make a copy the Cheetah datablock and script files.Change 1 line in the datablock
datablock WheeledVehicleData(CheetahCar) to datablock WheeledVehicleData(Car)
And change 1 line in the script file
function CheetahCar::onAdd(%this, %obj) to function Car::onAdd(%this, %obj)
Then I get a Cheetah using the default buggy wheels. Which I don't get as everything else is identical. I thought it might be a problem with having two declarations but even if I remove the original Cheetah from the game, this new copy comes up wrong. Can anyone else replicate this?
#6
12/31/2012 (1:46 pm)
Ah think I might have solved it. It seems the problem is just the name, it doesn't seem to like being called 'Car'. If I use another name like 'crapCar' it works.
#7
01/01/2013 (5:36 am)
In the past it was always bad practice to name a datablock with the same name as the shape. Evidently that oddity is still around...
#8
{Edit}
I resolved my problem in the other thread.
01/02/2013 (11:40 am)
@BigDaz, I could use that Tutorial about now. :-){Edit}
I resolved my problem in the other thread.
#9
01/02/2013 (2:39 pm)
It'll probably have to wait until the weekend now.
#10
01/12/2013 (10:38 am)
please in the next versions of Torque 3D MIT add some basic examples of vehicle rigs (cars and flying vehicles) is very hard try with old tutorials that not work with new versions.
#11
01/12/2013 (10:54 am)
@mr kat: T3D does include two wheeled vehicle examples, the Cheetah and a "dune-buggy". For a flying vehicle example there are several Resources and forum posts that demonstrate how to implement one. However, if anyone within the community wishes to donate a better or more up-to-date example through a pull request we could certainly review such an offering.
#12
Truly, I have to agree with mr kat.
Digging through all the forum posts, including those that need clarification and those with the answers and using Skype with my new community friend Noah, emailing Adam deGrandis for further clarification, and finally getting the Vehicles made and placed into the engine as a scripted object was (... sigh...) exhausting.
I feel as if:
"I have done the difficult for so long, with so little, that I now feel qualified to do the impossible with nothing at all"
01/12/2013 (10:57 am)
I have faith that BigDaz will get the tutorial finished.Truly, I have to agree with mr kat.
Digging through all the forum posts, including those that need clarification and those with the answers and using Skype with my new community friend Noah, emailing Adam deGrandis for further clarification, and finally getting the Vehicles made and placed into the engine as a scripted object was (... sigh...) exhausting.
I feel as if:
"I have done the difficult for so long, with so little, that I now feel qualified to do the impossible with nothing at all"
#13
01/12/2013 (11:09 am)
I'll admit that with my experience I find implementation of any of the vehicle types to be simple, and that is a bit of a problem. That experience makes it hard for me to judge how to reconcile somewhat dated resources for a newcomer's perspective. As just one person on the Steering Committee that directs the current and future development T3D I am certainly open to suggestions that would help clarify and/or simplify things of this nature. However, do keep in mind that our resources and time is very much limited.
#14
Many of us in the community understand what you mean. We often compensate by asking thousands of questions in the forums.
Sadly.. and I have done it too... The answers are too short and direct to the point. Technical writers for code and script are often the minority that understand a process partly because of your experience.
I agree that the Committee cannot be bogged down with revamping tutorials to explain entire processes from A to Z, and written in such a way that even the most simple thing could be understood. But I have a feeling that the majority of the community will require just that sort of thing in tutorials.
This is compounded with the variety of Modeling Software and the application to follow the Tutorials. For example, I use Lightwave, the Tutorials are mostly written for 3dsMax. Those that do not use 3dsMax ( or can afford it) are already at a disadvantage before we read the Tutorials.
I think the best way to help solve the problem you point out, is to get more people like BigDaz to submit there version of Tutorials to the committee and those that do not use 3dsMax should follow suit and submit a tutorial based on their modeling software. The committee could maybe then advise the Tutorial Author on weak points to get a final Tut that is understandable for the new people and still be Technical enough for the Advanced user like yourself.
01/12/2013 (12:33 pm)
@MichaelMany of us in the community understand what you mean. We often compensate by asking thousands of questions in the forums.
Sadly.. and I have done it too... The answers are too short and direct to the point. Technical writers for code and script are often the minority that understand a process partly because of your experience.
I agree that the Committee cannot be bogged down with revamping tutorials to explain entire processes from A to Z, and written in such a way that even the most simple thing could be understood. But I have a feeling that the majority of the community will require just that sort of thing in tutorials.
This is compounded with the variety of Modeling Software and the application to follow the Tutorials. For example, I use Lightwave, the Tutorials are mostly written for 3dsMax. Those that do not use 3dsMax ( or can afford it) are already at a disadvantage before we read the Tutorials.
I think the best way to help solve the problem you point out, is to get more people like BigDaz to submit there version of Tutorials to the committee and those that do not use 3dsMax should follow suit and submit a tutorial based on their modeling software. The committee could maybe then advise the Tutorial Author on weak points to get a final Tut that is understandable for the new people and still be Technical enough for the Advanced user like yourself.
#15
01/12/2013 (12:51 pm)
thankyou very much Michael, i never can see the vehicle examples because ever use the "Full Physx template" and they are only in the "Full Template", and now i am a little confused, if the vehicles are in the non Physx template how work their physics?, then please in the next versions of Torque 3D include some basic flying vehicle examples, perhaps possibly will be not very complicate following the car examples to make a flying vehicle. thanks.
#16
I'm using Softimage Modtool for the modelling which is free. It's a complete beginner tutorial so I'm assuming no prior knowledge of Softimage or Torque.
01/12/2013 (1:49 pm)
I'm working on the tutorial right now :) It's taken longer than I thought. I was trying to find a quick way to use keyboard steering instead of the mouse, but I don't think you can without editing the source code. I'm using Softimage Modtool for the modelling which is free. It's a complete beginner tutorial so I'm assuming no prior knowledge of Softimage or Torque.
#17
@mr kat: Torque's vehicles use a rigid physics solution that is independent of 3rd party physics systems. No work has been done to implement PhysX or Bullet based vehicles.
@BigDaz: keyboard steering is easily implemented through script. The functions for turning already exist, all you have to do is enable the keybinds. However, a return-to-center steering solution (requires a source mod) is ideal when using keyboard steering. This was recently implemented in the development branch.
01/12/2013 (2:28 pm)
@Scott: we can only try to do our best. Results may not be as quick as some may prefer, but all input from everyone is something that we consider. Right now I don't think anyone is officially committed to writing tutorials and guides, although we all are tasked with keeping the documentation up to date.@mr kat: Torque's vehicles use a rigid physics solution that is independent of 3rd party physics systems. No work has been done to implement PhysX or Bullet based vehicles.
@BigDaz: keyboard steering is easily implemented through script. The functions for turning already exist, all you have to do is enable the keybinds. However, a return-to-center steering solution (requires a source mod) is ideal when using keyboard steering. This was recently implemented in the development branch.
//In default.binds.cs vehicleMap.bind( keyboard, w, moveforward ); vehicleMap.bind( keyboard, s, movebackward ); vehicleMap.bind( keyboard, up, moveforward ); vehicleMap.bind( keyboard, down, movebackward ); vehicleMap.bind( keyboard, left, turnleft ); // added vehicleMap.bind( keyboard, right, turnright ); // added
#18
Good Luck to BigDaz with the tutorial.
01/12/2013 (3:22 pm)
Thanks Michael, a final question, can work the Torque vehicle physics with other Physx objects at same time in a game? (for example that the Cheetah can hit some Physx balls), I mean if i can use the torque vehicles (Cheetah and Buggy) in the the "Full Physx template" or I can not mix these physics systems?.Good Luck to BigDaz with the tutorial.
#19
Part 1 vimeo.com/57474314
Part 2 vimeo.com/57482910
Part 3 to come.
01/15/2013 (2:57 pm)
The first parts of my vehicle tutorial are online now.Part 1 vimeo.com/57474314
Part 2 vimeo.com/57482910
Part 3 to come.
#20
Just watched your Video Tutorials.
It was a good choice to start from the Modeling and on through to the Export.
You've explained what you were doing and why you did it. That sort of thing is what the Written and Video tutorials need to be like.
It doesn't leave a person wondering "why".
My opinion is, that if all or most of the tutorials were like this one, the entire community would have greater success. It brings all of the new people up to speed. Vroooom Vroooom.
01/15/2013 (6:51 pm)
Good Job!Just watched your Video Tutorials.
It was a good choice to start from the Modeling and on through to the Export.
You've explained what you were doing and why you did it. That sort of thing is what the Written and Video tutorials need to be like.
It doesn't leave a person wondering "why".
My opinion is, that if all or most of the tutorials were like this one, the entire community would have greater success. It brings all of the new people up to speed. Vroooom Vroooom.
Torque Owner Richard Ranft
Roostertail Games
datablock WheeledVehicleTire(CarTire : DefaultCarTire) { ... }Don't know if it'll make any difference, but stranger things have happened....