Game Development Community

Boat sinking slowly into the water

by Amr Bekhit · in Torque Game Engine · 01/04/2007 (5:38 am) · 3 replies

Hello all!

I've been trying to implement a boat in TGE and so what I've done so far is to implement it using a hover vehicle and then in the source code in hoverVehicle.cc, I've set sHoverVehicleGravity to 0 on line 30. That way, I would get the movement syle of the hoverVehicle but without the oddities that floating on water seemed to bring.

This seems to have worked, however while testing, I noticed that the boat very gradually sinks into the water after I've been moving it around for a while(doesn't seem to happen if the boat is stationary). What could be causing this?

Here's the script file for the ship:

datablock HoverVehicleData(GalleonData)
{
   scale = "2 2 2";
   observeThroughObject=true;
   firstpersononly=false;

   category               = "Galleons";
   shapeFile              = $galleonMesh;

   integration            = 4;
   collisionTol           = 0.1;
   contactTol             = 0.1;

   drag                   = 0.5;
   density                = 0.1; // Will float in water

   mass                   = 40;
   bodyFriction           = 1;
   bodyRestitution        = 0.1;

   mainThrustForce        = 500;
   reverseThrustForce     = 100;
   strafeThrustForce      = 0;

   stabSpringConstant     = 100;
   stabDampingConstant    = 1;

   dragForce              = 40;

   vertFactor             = 10;
   floatingThrustFactor   = 1;

   turboFactor            = 1.5;

   stabLenMin             = 0;
   stabLenMax             = 0;

   normalForce            = 1000;
   restorativeForce       = 500;

   steeringForce          = 200;
   gyroDrag               = 40;

   rollForce              = 100;
   pitchForce             = 0;

   floatingGravMag        = 0;

   brakingForce           = 200;
   brakingActivationSpeed = 1000;
};

function GalleonData::onAdd(%this,%obj)
{   
   %obj.mountImage(LeftCannonImage,0);
   %obj.mountImage(RightCannonImage,1);
}

function HoverVehicle::create(%VehicleDB)
{

   %obj = new HoverVehicle() 
   {
      dataHoverVehicleDB = %VehicleDB;
   };

   %obj.mountable = true;
   return(%obj);
}

--Amr

#1
01/04/2007 (4:43 pm)
*bump*
#2
01/04/2007 (5:13 pm)
I've had this happen before when I was messing around with a hover vehicle (a while back)
It seems to happen when you set the gravity to 0.

Have you tried gravity above 0?

If that doesn't work try setting the gravity to 0 and then setting the mass to 0 and see what happens.

It might help, maybe. If I get some free time I'll mess around and see what I can do with your datablock that you posted.
#3
01/06/2007 (1:26 pm)
Sorry for my late reply.

Which 'gravity' do you mean when you said
Quote:Have you tried gravity above 0?
. I couldn't find a gravity property in either the Vehicle or HoverVehicle datablocks. In the source code, the sHoverVehicleGravity is set to -20 by default and I turned it down to 0.

I've tried setting mass to 0, but unfortunately that crashes the engine.

I did temporarily solve the problem by setting the restorativeForce property to a high value, as I think that when thrusting forward on a hover vehicle, the nose of the vehicle might be tilting forwards and thus causing it to sink.

--Amr