Game Development Community

Flying Vehicles

by Neven Sosteric · in Technical Issues · 12/13/2006 (1:46 am) · 5 replies

I'm using Torque 1.5 and i'm trying to add a flying vehicle to the game for the past couple of days. I've searched and found lots of info and i managed to get a character in starter.fps to have mid-air control (like in Quake) and "Jet Pack" ability. That enables me to, sort of, fly it. What i had to do though is recompile Torque with changes made to player.h and player.cc. Also, it doesn't really give me the functionality of the flying vehicle you'd expect...for example, if i get up in the air and start going forward, and then rotate the player 90 degrees to the left, i'll still go in the same direction and not "forward" any more. Of course, you may call this expected behavior of some flying vehicles, but what i'd like my flying vehicle to act like is an airplane. When it turns, i want it's direction of movement to change as well.

Now i've seen in \sdk\engine\game\vehicles that there is a file flyingVehicle.cc which leads me to believe that torque allows for flying vehicles without the need to recompile the engine.

Can anyone explain me everything i need to do to get a flying vehicle in my game? Do i need a special model (with some special nodes), or will a standard player.dts work? Do i need to recompile the engine with some changes? What would be the example datablock and usage of those datablocks for a flying vehicle? Does anyone have a working example (with code) of a controllable "airplane like" vehicle in the game?

I'd appreciate any input you can give.

Kresimir

#1
12/13/2006 (2:02 am)
You're right, flyingvehicles are already in there. When you look in server/scripts/game.cs you'll see there in "createPlayer" a piece of code creating your usual player like this:

%player = new Player() {
     dataBlock = PlayerBody;
     client = %this;
   };

Here you change this into
%player = new FlyingVehicle() {
...

What happens in the code is that you now don't take anymore the player.cc class as player object but instead you use now the flying vehicle. Additionally you need a lot more of changes like a new datablock and a different DTS that has all nodes within for flying vehicles. What I can really recommand is to buy the warsparrow pack from bravetree. It shows to do to flying vehicle stuff right incl. scripts and the shape itself.

Ah, forgot to mention: There's also some stuff on TDN about this. Search for "flying vehicle".
#2
12/13/2006 (2:39 am)
Thanks!

Actually, that's exactly what i was trying to do all the time, but failed. I made jet.cs with a datablock copied from TDN (or somewhere), included "exec (.\jet.cs);" in game.cs and replaced "new WheeledVehicle" with "new FlyingVehicle" and "dataBlock = DefaultCar;" with "dataBlock = DefaultJet;" (DefaultJet being defined in the datablock in jet.cs). However, when i managed to get the buggy.dts (which i defined as a shape file for the DefaultJet) to display, i couldn't control it.

Are those extra nodes in the .dts important for controlling the flying vehicle or do they just display the extra special effects (particle system emitters, lights...)?

As you could probably already tell, i chose starter.racing for my starting point and tried to replace a "wheeled buggy" with a "flying buggy".
#3
12/13/2006 (3:46 am)
Well to be honest I can't remember it out of the brain right now, but I think yes, there are other nodes that are important. But in general your approach is right. I took also starter.racing as starting point and modified the game.cs accordingly to spawn a flyingvehicle. Do you have any errors in the console log?
#4
12/15/2006 (4:55 am)
Thank you very much for your help. I managed to get a warsparrow flying very quickly!
#5
12/15/2006 (5:29 am)
Glad to hear. Have fun! :-)