Game Development Community

FlyingVehicle vs. Player class

by Eric den Boer · in Torque Game Engine Advanced · 02/26/2009 (2:53 am) · 4 replies

Dear all,

Yesterday I received my Torque books (awesome!). However I'm left wondering with a small question... what's the best thing to do when you wish to create a player that's flying an aircraft?

Create a FlyingVehicle instance and build up the FlyingVehicle-datablocks? Or should I do that with a Player class instead?

Can both classes be controlled by the user?

Thanks in advance!

#1
02/26/2009 (8:54 am)
You can have the player be the vehicle when he/she joins the game. Or you can spawn as a player and then mount a vehicle and take control of it. It all depends on the gamestyle you wish to build towards.

Your "stock" vehicle choices are: wheeled, hover, and flying. There are several threads and/or resources that show how to set up datablocks for all of them, along with various control & mounting schemes.
#2
03/04/2009 (1:38 am)
Sorry for my late reply.

So it's possible to set a FlyingVehicle as a player-controlled object, i.e. the Player?
#3
03/04/2009 (9:06 am)
Yep, sure is. Inside of game.cs take a look at function GameConnection::createPlayer(), more specifically at this area:
// Create the player object
%player = new Player() 
{
    dataBlock = PlayerBody;
    client = %this;
};

You would change that with a call to new FLyingVehicle, and make the dataBlock point to a valid FlyingVehicleData
// The player is a vehicle!
%player = new FlyingVehicle()
{
    dataBlock = ScoutShip;
    client = %this;
};
And you may want to change your control scheme to make it more suitable for vehicle controls, but this should get you started in the right direction.
#4
03/04/2009 (12:55 pm)
Thank you :) We got the model into the game!