Game Development Community

Working boat?

by Edward Gardner · in Torque Game Engine · 03/01/2002 (6:26 am) · 16 replies

Anyone have a working boat model and script I can look at or steal?

#1
03/03/2002 (10:18 am)
Ed - I submitted a resource which hasn't been approved yet.

Check it out here:

www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2299
#2
03/03/2002 (10:45 am)
Hm, the download doesn't work (yet?)... :-/
#3
03/03/2002 (10:46 am)
Yeah, download is 404 :(

And the VERY latest HEAD seems to have broken all the vehicles. I don't suppose anyone has a working exe for this?

I'll be on IRC :)
#4
03/03/2002 (12:09 pm)
ok, so I guess there's no way around the approval process :-)

Ed - the Tutorial was built against the March 2 head.
#5
03/03/2002 (12:13 pm)
Adding a Watercraft class

[b]General[/b]

I've created a Watercraft class, which is quite parallel to the HoverVehicle class.
Someone with more time may want to change this to actually derive Watercraft
from Hovercraft properly. I didn't, since I wasn't sure where I was going to
go with it, until I got there. The Zodiac rubber boat is used as an instance
of a Watercraft.

To add the Watercraft class, and get a functioning boat into your game,
you need to do the following:

A) Download the latest Head release of TGE.
B) Incorporate the Watercraft class files into your engine project.
C) Add a Watercraft control script & vehicle model to your game.
D) Add Watercraft/zodiac support statements to existing scripts.
E) Modify the Collision and Dismount code to accommodate the Watercraft.
F) Test the Zodiac by running the game and inserting the boat with
   the Editor.


[b]Procedure[/b]

[b]A)[/b] If you do not have it, download the latest Head release of TGE. 
   Once you have that working, you can then add the WaterCraft class, 
   with some minor modifications. These modifications are made against
   the Head (which includes the racing demo).
   
[b]B)[/b] Incorporating the class files into your engine project.

   1) Download the 'WaterCraft.zip' file, and extract 'WaterCraft.cc' and
      'Watercraft.h' to the engine directory: engine\game\vehicles.
   
   2) Add 'WaterCraft.cc' to your engine project in the game:vehicles project folder
      (you can add 'WaterCraft.h' to your project as well, but it isn't
      necessary).
   3) Rebuild your project.

[b]C)[/b] Add the Watercraft control script & vehicle model.

   1) Extract the file 'zodiac.cs' from 'WaterCraft.zip' into the game directory:
      fps\server\scripts.
      
   2) Create a directory named 'fps\data\shapes\zodiac'. 
   
   3) Extract the archive file 'zodiac.zip' from the 'WaterCraft.zip' archive.
   
   4) Extract the shape file 'zodiac.dts' from 'zodiac.zip' into the new game directory:
      fps\data\shapes\zodiac.
      
   5) Extract the skin files: 'motorbase.png', 'motortop'.png, 'rubber.png', 'transoms.png' and
      'prop.png' into the new game directory: fps\data\shapes\zodiac.
      

[b]D)[/b] Add Watercraft/zodiac support statements to existing scripts.

   1) in the script 'fps\server\script\sgame.cs' add
   
      exec("./Zodiac.cs");
      
      to the function 'createGame();' after the last 'exec' statement.
      
[b]E)[/b] Modify the Collision and Dismount code to accommodate the Watercraft.

   1) In the file 'fps\server\scripts\player.cs' find the conditional that
      tests for vehicle type in the Armor::onCollision method:
      
      if ((%this.className $= WheeledVehicleData ) && %obj.mountVehicle &&
            %obj.getState() $= "Move" && %col.mountable) {
       
      
      and change it to this:
      
      [b]
      if ((%this.className $= WheeledVehicleData ||
            %this.className $= WaterCraftData) && %obj.mountVehicle &&
            %obj.getState() $= "Move" && %col.mountable) {
      [/b]
         
         This checks for the Watercraft data type to allow for mounting them.
         
    2) In the same file, find the Armor::doDismount method (just above onCollision)
       and locate the following section:
        
      if (%forced && %success == -1)
         %pos = %oldPos;
   
      %obj.mountVehicle = false;
      %obj.schedule(4000, "MountVehicles", true);
     
      
      and change it to this:
      
      [b]
      if (%forced && %success == -1)
         %pos = %oldPos;
      %obj.unmount();
      %obj.setControlObject(%obj);
      if(%obj.mVehicle)
      {
          %obj.mVehicle.getDataBlock().playerDismounted(%obj.mVehicle, %obj);
          %obj.mVehicle.mountable = true;
      }
      %obj.mountVehicle = false;
      %obj.schedule(4000, "MountVehicles", true);
      [/b]
          
       Note: the collision & mount/dismount code is based on the tutorial
             provided by Badguy, found in the GG Resources.
       
       
[b]F)[/b] Test the Zodiac by running the game and inserting the boat with
   the Editor.
   
      1) Start a mission that has plenty of water in it.
   
      2) Use the World Editor Creator (F11, F4) and select the
         Zodiac from the list of Shapes->Vehicles.
         
      3) Depending on how you have things set in your world, when you
         place the boat, it should spawn just a few metres above the
         water, then slowly settle into it. If you have wave action set on, 
         you may see the boat get swamped, then bob back up slowly.
        
      4) Run and jump into the boat to mount, or place the camera over the
         boat and use F7 to drop the player in from the camera position.
         
      5) Use your WASD action keys to control boat speed, use the mouse to
         control direction.
         
      6) Experiment with the settings in the datablock in 'Zodiac.cs' to adjust
         it's movement behaviour, beaching capabilities and so on.
         
 
 There is a posting in the SDK forums from a fellow about how to synchronize
 with the wave action correctly, but I can't find it ...


You can d/l WaterCraft.zip here



[ EDIT: changed 'setMountVehicle' to 'MountVehicles' ]
#6
03/03/2002 (12:13 pm)
REALLY?

Cause all my vehicles, including the cars, broke in that head.

Can you email me the zip so I can look at it?

edg@deckersds.com
#7
03/03/2002 (12:41 pm)
Posted at the same time :)

Do you have other kinds of vehicles working? Hover or flying?

If so, can I look at your force values, I am guessing physics is my problme now, rather than whaver Tim did to this head (rather, what he did revealed flaws in my script physisc :))
#8
03/03/2002 (1:14 pm)
I have the Drone provided by Badguy - it's a FlyingVehicle. I set the mass to 100, and the these force values:


maneuveringForce = 100000; // Horizontal jets (W,S,D,A key thrust)
steeringForce = 10000; // Steering jets (force applied when you move the mouse)
steeringRollForce = 5000; // Steering jets (how much you heel over when you turn)

And it now behaves not far from what it was before ...
#9
03/03/2002 (1:17 pm)
Time to start from scratch, lemme find badguys tutorial :(
#10
03/03/2002 (2:31 pm)
Errm, that download link doesn't work, either... :(
#11
03/03/2002 (2:50 pm)
Which, the 'watercraft.zip' link ? I just tested it, and it works fine.
#12
03/03/2002 (2:58 pm)
Nevermind, it'w working now... maybe it was my lame connection today... my ADSL isn't working at the moment :-(
Thanks for the code, though - I will check it as soon as my ASDL is back again... it's a pain to get the latest CVS with a 33k modem ...
#13
03/05/2002 (1:41 pm)
I'm not sure why, but the resource I submitted with the above has been sitting unapproved for quite a while now ... whoever does the approving, can you tell me why ?
#14
03/05/2002 (5:04 pm)
It can take anywhere from 1 day to 1 week. Just be patient.

GG is getting ready for the GDC, and Jeff Tunnel warned that they'd be pretty busy the next two weeks. Problem is we might not be getting approval on new tutorials during those two weeks :\
#15
03/05/2002 (10:12 pm)
Not impatient, just wondering. I saw half-a-dozen resources get posted after I posted mine for approval. Not a big deal.
#16
03/06/2002 (5:38 am)
BTW.

Not sure I said thanks for this :)

Thanks :)