Game Development Community

can wheeled vehicles float?

by Anthony Rosenbaum · in General Discussion · 06/03/2002 (3:11 pm) · 8 replies

I want to make an APC that floats on the water then rolls on the land, is this possible? When I drive my jeep in the water it rides on the landscape (underwater) can I change something so it will float on water? or do I need a new class all together?

#1
06/03/2002 (4:31 pm)
Just twiddle the density values for the water versus the vehicle (and its weight) in the script datablocks. Of course, you'll have to adjust everything else to match (like the player). Our Land Rover floats along quite nicely for about a minute or so then slowly slips below the surface...
#2
06/04/2002 (8:01 am)
could you show me an example. . . I'm not sure if I should be looking in the vehicles properties or in the general attributes in vehicle.cs I am guessing I am suppost to be doing something along this line
function VehicleData::onEnterLiquid(%data, %obj, %coverage, %type)
{
   switch(%type)
   {
      case 0:
         //Water
         APC //somthing here for this specific vehicle
         %obj.setHeat(0.0);
      case 1:
         //Ocean Water
         APC //somthing here for this specific vehicle
         %obj.setHeat(0.0);
      case 2:
         //River Water
         APC //somthing here for this specific vehicle
         %obj.setHeat(0.0);
      case 3:
         //Stagnant Water
         APC //somthing here for this specific vehicle
         %obj.setHeat(0.0);
      case 4:
         //Lava
         %obj.liquidDamage(%data, $VehicleDamageLava, $DamageType::Lava);
      case 5:
         //Hot Lava
         %obj.liquidDamage(%data, $VehicleDamageHotLava, $DamageType::Lava);
      case 6:    
         //Crusty Lava
         %obj.liquidDamage(%data, $VehicleDamageCrustyLava, $DamageType::Lava);
      case 7:
         //Quick Sand
   }
}
I'm not eve sure this is the right function to use for this. Can you show me what you did CERDIP ?!?!

EDIT
OR

should I be doing somthing like this ?
function APC::onEnterLiquid(%this, %obj)
{
      %obj.density = 0; //or very light   
}
AND
function APC::onExitLiquid(%this, %obj)
{
      %obj.density = 200; //or original value   
}
am I on the right track?
#3
06/04/2002 (11:57 am)
two places: in the waterblock in the .mis file:

new WaterBlock(Water1) 
   {
      position = "0 0 0";
      rotation = "1 0 0 0";
      scale = "2048 2048 29";
      liquidType = "Water";
      density = "9.0";
      viscosity = "10.0";
      .
      .
      .
   }

The higher the water density, the longer objects will take to sink or penetrate the surface, and the higher the viscosity, the slower they will move when fully submerged.


and in the vehicle datablock:

datablock WheeledVehicleData(Rover)
{
    .
    .
    .
    
   // Rigid Body
   mass = 800;
    .
    .
    .
}

The higher the mass (i think of the units as being kilograms), the faster the object will sink. You may also want to fiddle with other numbers, like body friction & body restitution.

I may be wrong, but I believe I saw that the volume of the rigid body (defined by the bounding box) is used with the mass in the vehicle object in the engine to establish density...so adjusting the mass in the script datablock and/or the bounding box size in your model will change the density of the vehicle. The ratio of the vehicle density to the water density will determine how well it floats, and for how long. If you spend an hour of trial & error with your model it should yield some useful numbers.
#4
06/04/2002 (12:13 pm)
ok I got it to float what about propulsion? when I drive in the water, as of right now, it is like I am a bouy just bobbing up and down only moving where interia takes me. How can I fix this?
#5
11/10/2002 (10:24 am)
I've set the density of the vehicle to 0.5 ( normal = 4.0 ) and I get it to float but it wont conform to the water. Say I did a nose dive into the water the back of the vehicle would stay up in the air for the whole time untill I leave the water. I noticed the hover vehicle does ok so Im wondering how to apply hover attributes to the wheeled vehicle. Could I parent it to the hover class?


EDIT

Well I wasnt able to parent it to the hover.
#6
11/12/2002 (9:21 am)
Anyone? I just need it to conform.
#7
11/12/2002 (3:10 pm)
Try casting some rays down to the water from the corners of the vehicle, and adjusting its position based on that. Make sure that bits further under the water "push" up harder...
#8
11/12/2002 (10:29 pm)
Even if I did ray casts and apply impulse the vehicle will be "IN" the water thus all 4 corners will read the cast as 0 distance.