Game Development Community

dev|Pro Game Development Curriculum

Gain full X,Y,Z control of your flyingVehicle

by Jesse Liles · 07/06/2009 (5:07 pm) · 14 comments

This resource changes the stock TGE flyingVehicle code to provide for controls to move and rotate the flyingVehicle freely on the X, Y, and Z axis. In addition, I have removed the
flight ceiling factored into the stock TGE code and made the flyingVehicle unaffected by gravity. The code herein is best applied to a space combat action game as it was originally written for that purpose. As well, it functions perfectly in correlation with Martin Schulz's fantastic Flight Game Example.

If you can't read .diff files, I apologize, but I guess now would be a good time to learn:

Changes to engine/game/vehicles/flyingVehicle.cc:
***************
*** 29,41 ****
                                         WaterObjectType          | PlayerObjectType     |
                                         StaticShapeObjectType    | VehicleObjectType    |
                                         VehicleBlockerObjectType | StaticTSObjectType);
  static U32 sServerCollisionMask = sCollisionMoveMask; // ItemObjectType
  static U32 sClientCollisionMask = sCollisionMoveMask;
  
! static F32 sFlyingVehicleGravity = -20;
  
  // Sound
  static F32 sIdleEngineVolume = 0.2;
  
  //
  const char* FlyingVehicle::sJetSequence[FlyingVehicle::JetAnimCount] =
--- 29,41 ----
                                         WaterObjectType          | PlayerObjectType     |
                                         StaticShapeObjectType    | VehicleObjectType    |
                                         VehicleBlockerObjectType | StaticTSObjectType);
  static U32 sServerCollisionMask = sCollisionMoveMask; // ItemObjectType
  static U32 sClientCollisionMask = sCollisionMoveMask;
  
! static F32 sFlyingVehicleGravity = 0;
  
  // Sound
  static F32 sIdleEngineVolume = 0.2;
  
  //
  const char* FlyingVehicle::sJetSequence[FlyingVehicle::JetAnimCount] =
***************
*** 48,60 ****
  
  const char* FlyingVehicleData::sJetNode[FlyingVehicleData::MaxJetNodes] =
  {
     "JetNozzle0",  // Thrust Forward
     "JetNozzle1",
     "JetNozzleX",  // Thrust Backward
!    "JetNozzleX",
     "JetNozzle2",  // Thrust Downward
     "JetNozzle3",
     "contrail0",   // Trail
     "contrail1",
     "contrail2",
     "contrail3",
--- 48,60 ----
  
  const char* FlyingVehicleData::sJetNode[FlyingVehicleData::MaxJetNodes] =
  {
     "JetNozzle0",  // Thrust Forward
     "JetNozzle1",
     "JetNozzleX",  // Thrust Backward
!    "JetNozzleY",
     "JetNozzle2",  // Thrust Downward
     "JetNozzle3",
     "contrail0",   // Trail
     "contrail1",
     "contrail2",
     "contrail3",
***************
*** 68,88 ****
  };
  
  
  //----------------------------------------------------------------------------
  
  IMPLEMENT_CO_DATABLOCK_V1(FlyingVehicleData);
  
  FlyingVehicleData::FlyingVehicleData()
  {
     maneuveringForce = 0;
     horizontalSurfaceForce = 0;
     verticalSurfaceForce = 0;
     autoInputDamping = 1;
     steeringForce = 1;
!    steeringRollForce = 1;
     rollForce = 1;
     autoAngularForce = 0;
     rotationalDrag = 0;
     autoLinearForce = 0;
     maxAutoSpeed = 0;
     hoverHeight = 2;
--- 68,90 ----
  };
  
  
  //----------------------------------------------------------------------------
  
  IMPLEMENT_CO_DATABLOCK_V1(FlyingVehicleData);
+ IMPLEMENT_CO_NETOBJECT_V1(FlyingVehicle);
  
  FlyingVehicleData::FlyingVehicleData()
  {
     maneuveringForce = 0;
+    engineForce = 0;
     horizontalSurfaceForce = 0;
     verticalSurfaceForce = 0;
     autoInputDamping = 1;
     steeringForce = 1;
!    steeringRollForce = 0.00;
     rollForce = 1;
     autoAngularForce = 0;
     rotationalDrag = 0;
     autoLinearForce = 0;
     maxAutoSpeed = 0;
     hoverHeight = 2;
***************
*** 133,145 ****
  
     // Resolve jet nodes
     for (S32 j = 0; j < MaxJetNodes; j++)
        jetNode[j] = shape->findNode(sJetNode[j]);
  
     //
!    maxSpeed = maneuveringForce / minDrag;
  
     delete si;
     return true;
  }
  
  void FlyingVehicleData::initPersistFields()
--- 135,147 ----
  
     // Resolve jet nodes
     for (S32 j = 0; j < MaxJetNodes; j++)
        jetNode[j] = shape->findNode(sJetNode[j]);
  
     //
!    maxSpeed = engineForce / minDrag;
  
     delete si;
     return true;
  }
  
  void FlyingVehicleData::initPersistFields()
***************
*** 147,158 ****
--- 149,161 ----
     Parent::initPersistFields();
  
     addField("jetSound", TypeAudioProfilePtr, Offset(sound[JetSound], FlyingVehicleData));
     addField("engineSound", TypeAudioProfilePtr, Offset(sound[EngineSound], FlyingVehicleData));
  
     addField("maneuveringForce", TypeF32, Offset(maneuveringForce, FlyingVehicleData));
+    addField("engineForce", TypeF32, Offset(engineForce, FlyingVehicleData));
     addField("horizontalSurfaceForce", TypeF32, Offset(horizontalSurfaceForce, FlyingVehicleData));
     addField("verticalSurfaceForce", TypeF32, Offset(verticalSurfaceForce, FlyingVehicleData));
     addField("autoInputDamping", TypeF32, Offset(autoInputDamping, FlyingVehicleData));
     addField("steeringForce", TypeF32, Offset(steeringForce, FlyingVehicleData));
     addField("steeringRollForce", TypeF32, Offset(steeringRollForce, FlyingVehicleData));
     addField("rollForce", TypeF32, Offset(rollForce, FlyingVehicleData));
***************
*** 191,202 ****
--- 194,206 ----
           SimObjectId writtenId = packed ? SimObjectId(jetEmitter[j]) : jetEmitter[j]->getId();
           stream->writeRangedU32(writtenId, DataBlockObjectIdFirst,DataBlockObjectIdLast);
        }
     }
  
     stream->write(maneuveringForce);
+    stream->write(engineForce);
     stream->write(horizontalSurfaceForce);
     stream->write(verticalSurfaceForce);
     stream->write(autoInputDamping);
     stream->write(steeringForce);
     stream->write(steeringRollForce);
     stream->write(rollForce);
***************
*** 226,237 ****
--- 230,242 ----
        if (stream->readFlag())
           jetEmitter[j] = (ParticleEmitterData*)stream->readRangedU32(DataBlockObjectIdFirst,
                                                                       DataBlockObjectIdLast);
     }
  
     stream->read(&maneuveringForce);
+    stream->read(&engineForce);
     stream->read(&horizontalSurfaceForce);
     stream->read(&verticalSurfaceForce);
     stream->read(&autoInputDamping);
     stream->read(&steeringForce);
     stream->read(&steeringRollForce);
     stream->read(&rollForce);
***************
*** 245,263 ****
     stream->read(&vertThrustMultiple);
  }
  
  
  //----------------------------------------------------------------------------
  
! IMPLEMENT_CO_NETOBJECT_V1(FlyingVehicle);
  
  FlyingVehicle::FlyingVehicle()
  {
     mSteering.set(0,0);
     mThrottle = 0;
     mJetting = false;
  
     mJetSound = 0;
     mEngineSound = 0;
  
     mBackMaintainOn = false;
     mBottomMaintainOn = false;
--- 250,272 ----
     stream->read(&vertThrustMultiple);
  }
  
  
  //----------------------------------------------------------------------------
  
! 
  
  FlyingVehicle::FlyingVehicle()
  {
     mSteering.set(0,0);
     mThrottle = 0;
     mJetting = false;
+ 
+    mManeuveringMod = 0.0;
+    mEngineMod = 0.0;
+    mAfterburnerMod = 0.0;
  
     mJetSound = 0;
     mEngineSound = 0;
  
     mBackMaintainOn = false;
     mBottomMaintainOn = false;
***************
*** 355,406 ****
     Parent::updateMove(move);
  
     if (move == &NullMove)
        mSteering.set(0,0);
  
     F32 speed = mRigid.linVelocity.len();
!    if (speed < mDataBlock->maxAutoSpeed)
!       mSteering *= mDataBlock->autoInputDamping;
  
-    // Check the mission area to get the factor for the flight ceiling
-    MissionArea * obj = dynamic_cast<MissionArea*>(Sim::findObject("MissionArea"));
-    mCeilingFactor = 1.0f;
-    if (obj != NULL)
-    {
-       F32 flightCeiling = obj->getFlightCeiling();
-       F32 ceilingRange  = obj->getFlightCeilingRange();
- 
-       if (mRigid.linPosition.z > flightCeiling)
-       {
-          // Thrust starts to fade at the ceiling, and is 0 at ceil + range
-          if (ceilingRange == 0)
-          {
-             mCeilingFactor = 0;
-          }
-          else
-          {
-             mCeilingFactor = 1.0f - ((mRigid.linPosition.z - flightCeiling) / (flightCeiling + ceilingRange));
-             if (mCeilingFactor < 0.0f)
-                mCeilingFactor = 0.0f;
-          }
-       }
-    }
- 
     mThrust.x = move->x;
     mThrust.y = move->y;
  
     if (mThrust.y != 0.0f)
        if (mThrust.y > 0)
           mThrustDirection = ThrustForward;
        else
           mThrustDirection = ThrustBackward;
-    else
-       mThrustDirection = ThrustDown;
- 
-    if (mCeilingFactor != 1.0f)
-       mJetting = false;
  }
  
  
  //----------------------------------------------------------------------------
  
  Point3F JetOffset[4] =
--- 364,389 ----
     Parent::updateMove(move);
  
     if (move == &NullMove)
        mSteering.set(0,0);
  
     F32 speed = mRigid.linVelocity.len();
!    //if (speed < mDataBlock->maxAutoSpeed)
!    //   mSteering *= mDataBlock->autoInputDamping;
!    mSteering *= mDataBlock->autoInputDamping;
  
     mThrust.x = move->x;
     mThrust.y = move->y;
+    mThrust.z = move->z;
+    mRolling = move->roll;
  
     if (mThrust.y != 0.0f)
        if (mThrust.y > 0)
           mThrustDirection = ThrustForward;
        else
           mThrustDirection = ThrustBackward;
  }
  
  
  //----------------------------------------------------------------------------
  
  Point3F JetOffset[4] =
***************
*** 423,505 ****
     Point3F xv,yv,zv;
     currPosMat.getColumn(0,&xv);
     currPosMat.getColumn(1,&yv);
     currPosMat.getColumn(2,&zv);
     F32 speed = mRigid.linVelocity.len();
  
!    Point3F force  = Point3F(0, 0, sFlyingVehicleGravity * mRigid.mass * mGravityMod);
     Point3F torque = Point3F(0, 0, 0);
  
     // Drag at any speed
     force  -= mRigid.linVelocity * mDataBlock->minDrag;
     torque -= mRigid.angMomentum * mDataBlock->rotationalDrag;
  
     // Auto-stop at low speeds
!    if (speed < mDataBlock->maxAutoSpeed) {
        F32 autoScale = 1 - speed / mDataBlock->maxAutoSpeed;
  
-       // Gyroscope
-       F32 gf = mDataBlock->autoAngularForce * autoScale;
-       torque -= xv * gf * mDot(yv,Point3F(0,0,1));
- 
        // Manuevering jets
        F32 sf = mDataBlock->autoLinearForce * autoScale;
        force -= yv * sf * mDot(yv, mRigid.linVelocity);
        force -= xv * sf * mDot(xv, mRigid.linVelocity);
!    }
  
-    // Hovering Jet
-    F32 vf = -sFlyingVehicleGravity * mRigid.mass * mGravityMod;
-    F32 h  = getHeight();
-    if (h <= 1) {
-       if (h > 0) {
-          vf -= vf * h * 0.1;
-       } else {
-          vf += mDataBlock->jetForce * -h;
-       }
-    }
-    force += zv * vf;
- 
     // Damping "surfaces"
!    force -= xv * speed * mDot(xv,mRigid.linVelocity) * mDataBlock->horizontalSurfaceForce;
!    force -= zv * speed * mDot(zv,mRigid.linVelocity) * mDataBlock->verticalSurfaceForce;
  
     // Turbo Jet
     if (mJetting) {
        if (mThrustDirection == ThrustForward)
!          force += yv * mDataBlock->jetForce * mCeilingFactor;
        else if (mThrustDirection == ThrustBackward)
!          force -= yv * mDataBlock->jetForce * mCeilingFactor;
!       else
!          force += zv * mDataBlock->jetForce * mDataBlock->vertThrustMultiple * mCeilingFactor;
     }
  
     // Maneuvering jets
!    force += yv * (mThrust.y * mDataBlock->maneuveringForce * mCeilingFactor);
!    force += xv * (mThrust.x * mDataBlock->maneuveringForce * mCeilingFactor);
  
     // Steering
     Point2F steering;
     steering.x = mSteering.x / mDataBlock->maxSteeringAngle;
!    steering.x *= mFabs(steering.x);
     steering.y = mSteering.y / mDataBlock->maxSteeringAngle;
!    steering.y *= mFabs(steering.y);
!    torque -= xv * steering.y * mDataBlock->steeringForce;
     torque -= zv * steering.x * mDataBlock->steeringForce;
  
     // Roll
!    torque += yv * steering.x * mDataBlock->steeringRollForce;
!    F32 ar = mDataBlock->autoAngularForce * mDot(xv,Point3F(0,0,1));
!    ar -= mDataBlock->rollForce * mDot(xv, mRigid.linVelocity);
!    torque += yv * ar;
  
-    // Add in force from physical zones...
     force += mAppliedForce;
  
     // Container buoyancy & drag
!    force -= Point3F(0, 0, 1) * (mBuoyancy * sFlyingVehicleGravity * mRigid.mass * mGravityMod);
     force -= mRigid.linVelocity * mDrag;
  
     //
     mRigid.force  = force;
     mRigid.torque = torque;
  }
--- 406,469 ----
     Point3F xv,yv,zv;
     currPosMat.getColumn(0,&xv);
     currPosMat.getColumn(1,&yv);
     currPosMat.getColumn(2,&zv);
     F32 speed = mRigid.linVelocity.len();
  
!    Point3F force  = Point3F(0, 0, mRigid.mass);
     Point3F torque = Point3F(0, 0, 0);
  
     // Drag at any speed
     force  -= mRigid.linVelocity * mDataBlock->minDrag;
     torque -= mRigid.angMomentum * mDataBlock->rotationalDrag;
  
     // Auto-stop at low speeds
!    //if (speed < mDataBlock->maxAutoSpeed) {
        F32 autoScale = 1 - speed / mDataBlock->maxAutoSpeed;
  
        // Manuevering jets
        F32 sf = mDataBlock->autoLinearForce * autoScale;
        force -= yv * sf * mDot(yv, mRigid.linVelocity);
        force -= xv * sf * mDot(xv, mRigid.linVelocity);
!    //}
  
     // Damping "surfaces"
!    //force -= xv * speed * mDot(xv,mRigid.linVelocity) * mDataBlock->horizontalSurfaceForce;
!    //force -= zv * speed * mDot(zv,mRigid.linVelocity) * mDataBlock->verticalSurfaceForce;
  
     // Turbo Jet
     if (mJetting) {
        if (mThrustDirection == ThrustForward)
!          force += yv * (mDataBlock->jetForce + mAfterburnerMod);
        else if (mThrustDirection == ThrustBackward)
!          force -= yv * (mDataBlock->jetForce + mAfterburnerMod);
     }
  
+    // Main engine thrust
+    force += yv * (mThrust.y * (mDataBlock->engineForce + mEngineMod));
+    
     // Maneuvering jets
!    force += xv * (mThrust.x * (mDataBlock->maneuveringForce + mManeuveringMod)); // Horizontal (left/right)
!    force += zv * (mThrust.z * (mDataBlock->maneuveringForce + mManeuveringMod)); // Vertical (up/down)
  
     // Steering
     Point2F steering;
     steering.x = mSteering.x / mDataBlock->maxSteeringAngle;
!    //steering.x *= mFabs(steering.x);
     steering.y = mSteering.y / mDataBlock->maxSteeringAngle;
!    //steering.y *= mFabs(steering.y);
!    torque -= xv * steering.y * mDataBlock->steeringForce;//xv
     torque -= zv * steering.x * mDataBlock->steeringForce;
  
     // Roll
!    torque += yv * (mRolling * (mDataBlock->rollForce + mManeuveringMod));
  
     force += mAppliedForce;
  
     // Container buoyancy & drag
!    force -= Point3F(0, 0, 1) * mRigid.mass;
     force -= mRigid.linVelocity * mDrag;
  
     //
     mRigid.force  = force;
     mRigid.torque = torque;
  }
***************
*** 694,705 ****
--- 658,673 ----
  
     // The rest of the data is part of the control object packet update.
     // If we're controlled by this client, we don't need to send it.
     if(stream->writeFlag(getControllingClient() == con && !(mask & InitialUpdateMask)))
        return retMask;
  
+    stream->write(mEngineMod);
+    stream->write(mManeuveringMod);
+    stream->write(mAfterburnerMod);
+ 
     stream->writeFlag(createHeightOn);
  
     stream->writeInt(mThrustDirection,NumThrustBits);
  
     return retMask;
  }
***************
*** 708,727 ****
--- 676,703 ----
  {
     Parent::unpackUpdate(con,stream);
  
     if(stream->readFlag())
        return;
  
+    stream->read(&mEngineMod);
+    stream->read(&mManeuveringMod);
+    stream->read(&mAfterburnerMod);
+ 
     createHeightOn = stream->readFlag();
  
     mThrustDirection = ThrustDirection(stream->readInt(NumThrustBits));
  }
  
  void FlyingVehicle::initPersistFields()
  {
     Parent::initPersistFields();
+       //Midhir - Speed modification
+    addField("engineMod",		TypeF32,	Offset(mEngineMod, FlyingVehicle));
+    addField("maneuveringMod",	TypeF32,	Offset(mManeuveringMod, FlyingVehicle));
+    addField("afterburnerMod",	TypeF32,	Offset(mAfterburnerMod, FlyingVehicle));
  }


And then in engine/game/vehicles/flyingVehicle.h:
***************
*** 40,51 ****
--- 40,52 ----
     };
     ParticleEmitterData* jetEmitter[MaxJetEmitters];
     F32 minTrailSpeed;
  
     //
     F32 maneuveringForce;
+    F32 engineForce;
     F32 horizontalSurfaceForce;
     F32 verticalSurfaceForce;
     F32 autoInputDamping;
     F32 steeringForce;
     F32 steeringRollForce;
     F32 rollForce;
***************
*** 108,131 ****
     AUDIOHANDLE mEngineSound;
  
     enum NetMaskBits {
        InitMask = BIT(0),
        HoverHeight = BIT(1)
     };
     bool createHeightOn;
     F32 mCeilingFactor;
  
     enum ThrustDirection {
        // Enums index into sJetActivationTable
        ThrustForward,
        ThrustBackward,
        ThrustDown,
        NumThrustDirections,
        NumThrustBits = 3
     };
!    Point2F mThrust;
     ThrustDirection mThrustDirection;
  
     // Jet Threads
     enum Jets {
        // These enums index into a static name list.
        BackActivate,
--- 109,137 ----
     AUDIOHANDLE mEngineSound;
  
     enum NetMaskBits {
        InitMask = BIT(0),
        HoverHeight = BIT(1)
     };
+    F32 mEngineMod;
+    F32 mManeuveringMod;
+    F32 mAfterburnerMod;
+ 
     bool createHeightOn;
     F32 mCeilingFactor;
  
     enum ThrustDirection {
        // Enums index into sJetActivationTable
        ThrustForward,
        ThrustBackward,
        ThrustDown,
        NumThrustDirections,
        NumThrustBits = 3
     };
!    Point3F mThrust;
!    F32 mRolling;
     ThrustDirection mThrustDirection;
  
     // Jet Threads
     enum Jets {
        // These enums index into a static name list.
        BackActivate,
This should be all the changes needed in the source code, so you should now recompile the engine and place the new executables appropriately.

To facilitate actually _using_ the new flying physics, there's a few things that need to be added to the default.bind.cs, this really depends on your game, so I'm leaving the implementation up to you. These functions will filter out a somewhat problematic issue with steering too quickly, wherein your vehicle will begin rotating in the opposite direction of the mouse's movement. These are dirty, dirty hacks, but they work to prevent the problem. It also adds a line that will allow you to use $Pref::Input::MouseInverted = true to invert the pitch of the vehicle (like an airplane):
function yaw(%val)
{
   %maa = getMouseAdjustAmount(%val);
   %yaw = 0.0;
   if (($mvYaw + %maa) > 3.0) %yaw = 3.0;
   else if (($mvYaw + %maa) < -3.0) %yaw = -3.0;
   if (%yaw != 0.0) $mvYaw = %yaw;
   else $mvYaw += %maa;
}

function pitch(%val)
{
   %maa = getMouseAdjustAmount(%val);
   if ($pref::Input::MouseInverted) %maa = (0 - %maa);
   %pitch = 0.0;
   if (($mvPitch + %maa) > 3.0) %pitch = 3.0;
   else if (($mvPitch + %maa) < -3.0) %pitch = -3.0;
   if (%pitch != 0.0) $mvPitch = %pitch;
   else $mvPitch += %maa;
}

And these are the basic controls for normal movement:
//--------------------------------------------------------------------
// Movement Keys
//--------------------------------------------------------------------

function rollleft(%val)
{$mvRollLeftSpeed = %val;}

function rollright(%val)
{$mvRollRightSpeed = %val;}

function moveleft(%val)
{$mvLeftAction = %val;}

function moveright(%val)
{$mvRightAction = %val;}

function moveforward(%val)
{$mvForwardAction = %val;}

function movebackward(%val)
{$mvBackwardAction = %val;}

function moveup(%val)
{$mvUpAction = %val;}

function movedown(%val)
{$mvDownAction = %val;}

moveMap.bind( keyboard, a, moveleft );
moveMap.bind( keyboard, d, moveright );
moveMap.bind( keyboard, q, rollleft );
moveMap.bind( keyboard, e, rollright );
moveMap.bind( keyboard, lcontrol, movedown );
moveMap.bind( keyboard, space, moveup );
moveMap.bind( keyboard, w, moveforward );
moveMap.bind( keyboard, s, movebackward );
moveMap.bind( mouse, xaxis, yaw );
moveMap.bind( mouse, yaxis, pitch );

And finally you'll want to add a few values to your FlyingVehicleData datablock:
engineForce = 800;           // Move forward/back speed (W and S keys)
   maneuveringForce = 800;      // Strafe left/right speed (A and D keys)
   cameraRoll = true;           // Roll the camera with the vehicle


After you've got all of this working, you'll be able to set the engineMod, manueveringMod, and afterburnerMod variables to adjust the movement speed of individual flyingVehicle instances.

If you need a working flyingVehicle datablock I HIGHLY recommend the Flight Game Example from Martin Schulz and Decane Studios

#1
07/06/2009 (6:05 pm)
Useful indeed!
#2
07/06/2009 (6:17 pm)
nice resource mate. I will look over it in more details later, but it looks to be a nice fit with once of my projects.
#3
07/06/2009 (6:20 pm)
Very useful!... I have some other things to finish, but this is indeed one of my tasks to complete.
#4
07/07/2009 (12:04 am)
Hi,
does this work with TGEA as well? Seems like time for a little descent-remake ;-)
#5
07/07/2009 (6:45 am)
oh, if only someone would soup up the hoverVehicle code.....
hint hint
#6
07/07/2009 (2:32 pm)
Andy: As far as I know this shouldn't interfere with any standard flying vehicle implementation in any Torque engine. I'm going to be attempting to get it working in TGEA today so I'll let you know if there are any significant changes that need to be made.
#7
07/07/2009 (2:51 pm)
Will be checking this out soon, appreciate the resource Jesse!
#8
07/07/2009 (3:28 pm)
Confirmed, this resource works just fine in TGEA.
#9
07/07/2009 (11:33 pm)
Jesse, thanks for trying out. As soon as I get time I am going to implement this as well.
#10
11/10/2009 (12:57 pm)
What program did you use to create the .diff file?
#11
11/18/2009 (2:34 am)
I have tried using this on a totally clean version of TGEA 1.81 and have a bug where if you use more than one steering command after a short while the vehicle will shoot forward very fast and then the game crashes indicating it travelled fasdter than the engine could process.

The problem becomes more apparent and happens far faster if you increase the value of engineForce.

Has anyone else seen this and if so do you have a solution?
#12
03/08/2011 (8:48 am)
Not meaning to bring this back from the dead, but I tried this in a Torque 3D engine, and I get the exact same problem as Ron, has anyone been able to fix this?
#13
03/11/2011 (6:55 am)
I'm not 100% sure on this, but I re-implemented this resource, but didnt add the 'engineMod', 'maneuveringMod' or 'afterburnerMod', or make any changes to the network packing, so basically just update the flyingvehicle.h with the Point3f Thrust ( I intend to build on this at a later date for my game ), and most of the changes for FlyingVehicle::updateMove and FlyingVehicle::updateForces.

However, Jesse comments out this:

...
    // Auto-stop at low speeds  
    //if (speed < mDataBlock->maxAutoSpeed) {  
       F32 autoScale = 1 - speed / mDataBlock->maxAutoSpeed;  
     
       // Manuevering jets  
       F32 sf = mDataBlock->autoLinearForce * autoScale;  
       force -= yv * sf * mDot(yv, mRigid.linVelocity);  
       force -= xv * sf * mDot(xv, mRigid.linVelocity);  
    //}
...

And this is where I'm not 100% sure, but, if you DONT comment that if() check out, it doesnt seem to crash like myself and Ron find, but I'l admit I haven't yet tested this extensively, but it seems to have stopped the bug for me.
#14
07/05/2011 (3:59 am)
As I've recently been using this code in a new T3D game I'm working on, I have also encountered this issue you're describing. When using a faster vehicle it may be necessary to increase the value of maxAutoSpeed in the vehicle's datablock. It may take some trial and error to find a happy value but during my testing, it appears to completely resolve the problem without adding the commented lines back into the engine code.