Game Development Community

Swimming

by Lee-Orr Orbach · in Torque Game Engine · 06/24/2005 (1:52 am) · 3 replies

Hey!!! I wanted to know if someone knows how to make the Starter.FPS player swim in the water, or float?

#1
06/24/2005 (3:50 am)
I once needed boats, and I added this in my Player.cc code, in updateMove:

// Determine ground contact normal. Only look for contacts if
   // we can move.
   VectorF contactNormal;
   bool jumpSurface = false, runSurface = false;
   if (!isMounted())
      findContact(&runSurface,&jumpSurface,&contactNormal);
   if (jumpSurface)
      mJumpSurfaceNormal = contactNormal;

[b]
   //WE SWIM!!!
   if (mWaterCoverage >= 0.1)
   {
	   runSurface = true;
	   contactNormal.set(0,0,1);
   }
[/b]

All my bots were boats, so they had to 'swim'. Add a varible if you want your players to be able to swim or not. Of course, you will have to add an animation for a swimming model.

And no, that won't addapt to waves ;)
#2
06/24/2005 (5:26 am)
There is a swimming resource

http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4348

HTH
#3
06/24/2005 (12:00 pm)
Thanks! it really helped!

O
- )
O