T3DB2 Flying vehicle class
by Donald Teal · in Torque 3D Professional · 08/12/2010 (4:16 pm) · 25 replies
I noticed in the documentation that there is a flying vehicle class. I have a model with the required nodes as per the documentaiont.
Can someone point me to documentation or walk me through the steps to get the flying vehicle class to work?
using it like a buggy hasnt worked :(
thanks
Can someone point me to documentation or walk me through the steps to get the flying vehicle class to work?
using it like a buggy hasnt worked :(
thanks
About the author
#2
The model used for the FlyingVehicle has the following requirements:
Collision mesh
A convex collision mesh at detail size -1.
JetNozzle0-1 nodes
Particle emitter nodes used when thrusting forward.
JetNozzle2-3 nodes
Particle emitter nodes used when thrusting downward.
JetNozzleX, JetNozzleY nodes
Particle emitter nodes used when thrusting backward.
contrail0-3 nodes
Particle emitter nodes used when generating contrails.
activateBack animation
Non-cyclic animation sequence played when the vehicle begins thrusting forwards.
maintainBack animation
Cyclic animation sequence played after activateBack when the vehicle continues thrusting forwards.
activateBot animation
Non-cyclic animation sequence played when the vehicle begins thrusting upwards.
maintainBot animation
Cyclic animation sequence played after activateBot when the vehicle continues thrusting upwards.
08/12/2010 (4:42 pm)
Additionally, the CHM manual lists the requirements for the model:The model used for the FlyingVehicle has the following requirements:
Collision mesh
A convex collision mesh at detail size -1.
JetNozzle0-1 nodes
Particle emitter nodes used when thrusting forward.
JetNozzle2-3 nodes
Particle emitter nodes used when thrusting downward.
JetNozzleX, JetNozzleY nodes
Particle emitter nodes used when thrusting backward.
contrail0-3 nodes
Particle emitter nodes used when generating contrails.
activateBack animation
Non-cyclic animation sequence played when the vehicle begins thrusting forwards.
maintainBack animation
Cyclic animation sequence played after activateBack when the vehicle continues thrusting forwards.
activateBot animation
Non-cyclic animation sequence played when the vehicle begins thrusting upwards.
maintainBot animation
Cyclic animation sequence played after activateBot when the vehicle continues thrusting upwards.
#3
Wow! Exceeded post word limit! Example datablock posted below.
08/12/2010 (5:39 pm)
- Create a flying vehicle datablock.
- Spawn and set control for a vehicle based game or allow mounting (I think that stock scripts got changed to only allow wheeled vehicles) if main gameplay is ambulatory player based.
Wow! Exceeded post word limit! Example datablock posted below.
#4
Here is an example datablock that does work in my Torque3D based project:
Also keep in mind that if you are missing the required jet nodes that the game will crash when trying to instantiate a flying vehicle.
08/12/2010 (5:42 pm)
Hmm... all the nicely commented fields causes the example datablock to exceed word limit... so splitting datablock into 2 parts.Here is an example datablock that does work in my Torque3D based project:
datablock FlyingVehicleData(ClayScout)
{
category = "Vehicles"; // category for the editor
className = ClayFlyer; // script class namespace
shapeFile = "art/shapes/kilnwars/kilnscout.dts";
// Allowable weapon inventory items
// Just be aware that vehicles can have weapons ;)
// Explosion and debris setup
explosion = BigClayExplosion;
underwaterExplosion = WetClayExplosion;
explosionDamage = 40; // How much damage is applied through the radiusDamage function call
explosionRadius = 20; // Radius for the radiusDamage function call
debris = BigClayDebris;
debrisShapeName = "art/shapes/kilnwars/kilnscout_debris.dts"; // Debris shape (contains the explosion parts)
renderWhenDestroyed = false; // don't render normal shape when destroyed, only debris shape
// Sounds
jetSound = FlyerThrustSound;
engineSound = FlyerEngineSound;
// Object Impact Damage
collDamageThresholdVel = 10.0;
collDamageMultiplier = 0.05;
minImpactSpeed = 0.5; // If hit ground at speed above this then it's an impact. Meters / second
speedDamageScale = 0.5;
// Misc
computeCRC = true;
// Damage/Energy
maxDamage = 150; // total damage until explosion
maxEnergy = 200;
energyPerDamagePoint = 150;
destroyedLevel = 1.0;
rechargeRate = 0.4;
softImpactSpeed = 2; // This is a soft hit
hardImpactSpeed = 6; // This is a hard hit
// *** PHYSICS PROPERTIES SHOWN IN NEXT POST ***
// Velocities
softSplashSoundVelocity = 10.0;
mediumSplashSoundVelocity = 15.0;
hardSplashSoundVelocity = 20.0;
exitSplashSoundVelocity = 10.0;
// Emitter stuff
minTrailSpeed = 15; // The speed at which contrail shows up at
trailEmitter = FlyerContrailEmitter;
forwardJetEmitter = FlyerJetEmitter;
backwardJetEmitter = FlyerJetEmitter;
downJetEmitter = FlyerJetEmitterDown;
splashEmitter = VehicleFoamEmitter; // water splash stuff
//dustEmitter = DustEmitter; // dust emitter when hovering over the ground
//triggerDustHeight = 8; // DONT THINK THIS WORKS??
dustHeight = 8;
// Damage emitters
damageEmitter[0] = LightVDamageFx;
damageEmitter[1] = HeavyVDamageFx;
damageEmitter[2] = DestroyedVDamageFx;
damageEmitterOffset[0] = "0 0 0";
damageLevelTolerance[0] = 0.3;
damageLevelTolerance[1] = 0.7;
numDmgEmitterAreas = 1;
// camera
cameraRoll = true; // Roll the camera with the vehicle
cameraMaxDist = 6; // Far distance from vehicle
cameraOffset = 1.5; // Vertical offset from camera mount point
cameraLag = 0.1; // Velocity lag of camera
cameraDecay = 0.75; // Decay per sec. rate of velocity lag
};Also keep in mind that if you are missing the required jet nodes that the game will crash when trying to instantiate a flying vehicle.
#5
08/12/2010 (5:43 pm)
Following portion was extracted from previous post and pasted here due to post word limit -- don't forget to include these in the above datablock example!// Physics -- following fields commented from several sources on forums, TDN, and FGE drag = 0.2; density = 1.0; minDrag = 90; // Linear Drag (eventually slows you down when not thrusting...constant drag) rotationalDrag = 10; // Anguler Drag (dampens the drift after you stop moving the mouse...also tumble drag) maxAutoSpeed = 15; // Autostabilizer kicks in when less than this speed. (meters / second) autoAngularForce = 15; // Angular stabilizer force (this force levels you out when autostabilizer kicks in) autoLinearForce = 15; // Linear stabilzer force (this slows you down when autostabilizer kicks in) autoInputDamping = 0.95; // Dampen control input so you don't` whack out at very slow speeds maxSteeringAngle = 5; // Max radiens you can rotate the wheel. Smaller number is more maneuverable. horizontalSurfaceForce = 10; // Horizontal center "wing" (provides "bite" into the wind for climbing/diving and turning) verticalSurfaceForce = 100; // Vertical center "wing" (controls side slip. lower numbers make MORE slide.) maneuveringForce = 3900; // Horizontal jets (W,S,D,A key thrust) steeringForce = 700; // Steering jets (force applied when you move the mouse) steeringRollForce = 8; // Steering jets (how much you heel over when you turn) 8 rollForce = 70; // Auto-roll (self-correction to right you after you roll/invert) hoverHeight = 8; // Height off the ground at rest createHoverHeight = 8; // Height off the ground when created jetForce = 3700; // Afterburner thrust (this is in addition to normal thrust) minJetEnergy = 55; // Afterburner can't be used if below this threshhold. jetEnergyDrain = 0.7; // Energy use of the afterburners (lower number is less drain) vertThrustMultiple = 10.0; integration = 3; // Physics integration: TickSec/Rate collisionTol = 0.1; // Collision distance tolerance contactTol = 0.1; // Contact velocity tolerance mass = 100; // Mass of the vehicle bodyFriction = 0; // Don't change this. bodyRestitution = 0.5; // When you hit the ground, how much you rebound. (between 0 and 1) minRollSpeed = 0; // Don't change this.
#6
I am sure I will have lots of more questions once I dig into this
08/12/2010 (6:22 pm)
Thanks to both of you guys, I will try this out and see what happens.I am sure I will have lots of more questions once I dig into this
#7
08/13/2010 (4:43 am)
@Michael Hall .. could you contact me at info[at]ducksden.com I have some questions i would like to ask you off line.
#8
EDIT: dust and jet emitters do work!
08/18/2010 (8:34 am)
Additional notes for future reference:- Camera, mount, and eye nodes appear to be the only *required* nodes to make a flying vehicle work.
- triggerDustHeight/dustEmitter functionality appears broken -- this worked in TGE/TGEa.
- the jetNozzle nodes seem to be nonfunctional.
EDIT: dust and jet emitters do work!
#9
08/19/2010 (6:07 am)
Quote:They did. Said check is unnecessary. Go to scripts/server/player.cs and find the Armor::onCollision callback. Find this line:
Spawn and set control for a vehicle based game or allow mounting (I think that stock scripts got changed to only allow wheeled vehicles)
if ((%db.getClassName() $= "WheeledVehicleData" ) && %obj.mountVehicle && %obj.getState() $= "Move" && %col.mountable)Change it to
if (%obj.mountVehicle && %obj.getState() $= "Move" && %col.mountable)Logic being that if the player can mount a vehicle and the vehicle is mountable then there is no need for the classname check. The mountVehicle bool is pre-set in Armor::onAdd(), and the mountable bool for vehicles is pre-set in Vehicle::onAdd(). These can be overridden on a per object basis.
#10
Thanks for all your help. I now have a temp flying vehicle, all I have to do now is modify my model and change a few lines in the datablock and my Battle Dirigible will be ready to fly.
Of course I still need to work out Gunner positions and how to allow other players to fill those spots. But baby steps first
Thanks again
08/19/2010 (6:19 am)
@MikeThanks for all your help. I now have a temp flying vehicle, all I have to do now is modify my model and change a few lines in the datablock and my Battle Dirigible will be ready to fly.
Of course I still need to work out Gunner positions and how to allow other players to fill those spots. But baby steps first
Thanks again
#11
That functionality was never really fully tested though when I added the vehicle scripts, but it should give you an indication of how to fill your Gunner positions. I know that adding working passenger controlled vehicle turrets will require additional changes to incorporate turrents.
I noticed that the damage control methods were removed at some point, but hopefully some good vehicle script tidbits still exist in stock code.
08/19/2010 (6:29 am)
If you have the additional mount nodes in your model I *believe* there are still some basic findSeat/changeSeat functions for passengers in the stock vehicle.cs script. That functionality was never really fully tested though when I added the vehicle scripts, but it should give you an indication of how to fill your Gunner positions. I know that adding working passenger controlled vehicle turrets will require additional changes to incorporate turrents.
I noticed that the damage control methods were removed at some point, but hopefully some good vehicle script tidbits still exist in stock code.
#12
You said in post 9 that the vehicle classname check is not needed but could it be used to limit certain player datablocks from being able to mount certain vehicle classes? or is there a better way to do this?
08/19/2010 (11:30 am)
@MikeYou said in post 9 that the vehicle classname check is not needed but could it be used to limit certain player datablocks from being able to mount certain vehicle classes? or is there a better way to do this?
#13
For a basic can/can't option I would handle that through my scripted class onAdd() for the player data and set the mountVehicle bool accordingly. For example I have an Armor "class" and a Pilot "class" the two differing onAdd() callbacks read like this:
But that simply makes it either an on or off option for mounting vehicles. For something more complicated like certain players only being able to mount certain vehicles then the classname check would probably be best if using stock code -- although you would have to list your exceptions for both players and vehicle datablocks.
I personally would end up rewriting the vehicle and player onAdd callbacks as well as the mount function to check for pilot, passengerOnly, or noVehicleMounting properties and do the appropriate thing depending.
08/19/2010 (2:33 pm)
There are several ways of handling that. For a basic can/can't option I would handle that through my scripted class onAdd() for the player data and set the mountVehicle bool accordingly. For example I have an Armor "class" and a Pilot "class" the two differing onAdd() callbacks read like this:
function Pilot::onAdd(%this, %obj)
{
// Vehicle timeout
%obj.mountVehicle = true; // we drive!
// Default dynamic armor stats
%obj.setRechargeRate(%this.rechargeRate);
%obj.setRepairRate(0);
}
function Armor::onAdd(%this, %obj)
{
// Vehicle timeout
%obj.mountVehicle = false; // cannot mount vehicles
// Default dynamic armor stats
%obj.setRechargeRate(%this.rechargeRate);
%obj.setRepairRate(0);
}But that simply makes it either an on or off option for mounting vehicles. For something more complicated like certain players only being able to mount certain vehicles then the classname check would probably be best if using stock code -- although you would have to list your exceptions for both players and vehicle datablocks.
I personally would end up rewriting the vehicle and player onAdd callbacks as well as the mount function to check for pilot, passengerOnly, or noVehicleMounting properties and do the appropriate thing depending.
#14
Okay I am at the point that my dirigible is in game, can be mounted and can be flown.
Which has exposed a very big bug with T3D1.1B2. the waterblocks/water plains roll with the camera.
In otherwords if you are flying in a mission that has a waterblock or water plain, and you roll. the waterblock/water plane will roll with the vehicle. But this was reported in another thread, and is besides my next question.
Now I am modifying the datablock you provided to give it custom flight characteristics and here is where I am falling down.
My flying vehicle is a dirigible, it moves more like a helicopter than a plane. so there arent barrel rolls or loops, or pitching up and down.
so I figured
SteeringRollForce= 0; would stop the vehicle from rolling. - Nope it didnt
I changed minDrag=90; to minDrag=99; just to give it more drag and make it slow down quicker. didnt seem to change anything.
So I guess my question is, what am I missing to give my vehicle more of a blimp type movement.
08/19/2010 (3:06 pm)
@MikeOkay I am at the point that my dirigible is in game, can be mounted and can be flown.
Which has exposed a very big bug with T3D1.1B2. the waterblocks/water plains roll with the camera.
In otherwords if you are flying in a mission that has a waterblock or water plain, and you roll. the waterblock/water plane will roll with the vehicle. But this was reported in another thread, and is besides my next question.
Now I am modifying the datablock you provided to give it custom flight characteristics and here is where I am falling down.
My flying vehicle is a dirigible, it moves more like a helicopter than a plane. so there arent barrel rolls or loops, or pitching up and down.
so I figured
SteeringRollForce= 0; would stop the vehicle from rolling. - Nope it didnt
I changed minDrag=90; to minDrag=99; just to give it more drag and make it slow down quicker. didnt seem to change anything.
So I guess my question is, what am I missing to give my vehicle more of a blimp type movement.
#15
Try these adjustments:
If experimentation with those above properties fails you you might could give the HoverVehicle class a try. It might be more conducive to faking a dirigible than a FlyingVehicle, maybe, or maybe not... hard to say without actually trying. Hovers do however have their own headaches and issues ;)
08/19/2010 (3:45 pm)
Balancing/tuning vehicle datablocks can be tricky, if downright hard. Which is why I think vehicles in Torque have been neglected for so long by GG/TP.Try these adjustments:
- minDrag - change to something more substantial. Double or even triple the current value
- steeringRollForce - instead of adjusting downwards, increase this force. Seems odd, but limited (slowed down) the rolling when I tried it.
- maxSteeringAngle - maybe try increasing this to make the steering controls a bit less responsive
- maxAutoSpeed - increase this. I kicked it up by a multiple of 10 and it made it drastically more *stable*
If experimentation with those above properties fails you you might could give the HoverVehicle class a try. It might be more conducive to faking a dirigible than a FlyingVehicle, maybe, or maybe not... hard to say without actually trying. Hovers do however have their own headaches and issues ;)
#16
i will have to tackle hovervehicles soon as I have another implemetaion that will work off of that
then I have a "walker" that I will have to figure out. it has legs instead of wheels and not sure how to handle that in the vehicle class
but first things first
08/19/2010 (4:04 pm)
thanks Mike. i will have to tackle hovervehicles soon as I have another implemetaion that will work off of that
then I have a "walker" that I will have to figure out. it has legs instead of wheels and not sure how to handle that in the vehicle class
but first things first
#17
About "walkers": it's a little known trick but you can mount players to other players - I faked (ie. big ugly hackaround!) mountable mechs in Tribes using that principle a long time ago. But in Torque with source access you could derive a vehicle class from the player class so that you had the movement code of something that walks but is still treated as a vehicle. That's how we handled horses in another project and also, I'm pretty sure, how the Hercs were managed in the abandoned Starsiege project from a few years ago.
Gonna work some more this weekend on that vehicle Resource I mentioned and a HoverVehicle example is on the agenda - so maybe that will come in handy for you. But before then I've still got to verify some problems with FlyingVehicles in T3D and submit some actual bug reports
08/19/2010 (4:25 pm)
Glad to help.About "walkers": it's a little known trick but you can mount players to other players - I faked (ie. big ugly hackaround!) mountable mechs in Tribes using that principle a long time ago. But in Torque with source access you could derive a vehicle class from the player class so that you had the movement code of something that walks but is still treated as a vehicle. That's how we handled horses in another project and also, I'm pretty sure, how the Hercs were managed in the abandoned Starsiege project from a few years ago.
Gonna work some more this weekend on that vehicle Resource I mentioned and a HoverVehicle example is on the agenda - so maybe that will come in handy for you. But before then I've still got to verify some problems with FlyingVehicles in T3D and submit some actual bug reports
#18
I will have to talk with you more about the hack in deriving a vehicle class from the player class.
I have a nice dragon charactor that would make a great mount :)
08/19/2010 (5:02 pm)
look forward to seeing any more examples you may come up with, I will have to talk with you more about the hack in deriving a vehicle class from the player class.
I have a nice dragon charactor that would make a great mount :)
#19
For example
08/19/2010 (10:43 pm)
To get the dustEmitter for the vehicle to work I had forgotten an important step. You have to create a pseudo material that is mapped to the terrain material that you wish to emit dust - doing so is what enables player footstep dust as well as the vehicle liftoff/hover dust.For example
singleton Material( TerrainFX_Sanddust )
{
mapTo = "sand"; // this is the name of the terrain material
showDust = true; // self explanatory
materialTag0 = "RoadAndPath";
};Creating one of these for each terrain material type will let you define custom footstep sounds as well... but that's another topic/example ;)
#20
Can't get my animated thrusters to work, but then they used ifls which no longer work anyway.
Other than making sure of the watersplashes and sounds, the FlyingVehicle aspect of the vehicle resource I'm working on is practically complete. Still need to push vehicle specific actionMaps and guis but that will come eventually.
08/20/2010 (12:45 am)
function vehBoost(%val)
{
$mvTriggerCount3++;
}
moveMap.bind(keyboard, b, vehBoost); // could be assigned to mouse button1 if desiredJet emitters only emit when boosting. Can't get my animated thrusters to work, but then they used ifls which no longer work anyway.
Other than making sure of the watersplashes and sounds, the FlyingVehicle aspect of the vehicle resource I'm working on is practically complete. Still need to push vehicle specific actionMaps and guis but that will come eventually.
Employee Michael Perry
ZombieShortbus
Vehicle Guides
Datablocks
I have not used FlyingVehicle in a long time, so I'm do not have recent code or assets to give it a shot.