Game Development Community

Swimming?

by Luke Jones · in Torque Game Engine · 04/06/2004 (10:18 pm) · 15 replies

Anyone figured ths out?

I found a few threads and a resource, but none do it in a satisfactory way.
Need to get the player to swim in the direction faced when in water. (quake style i guess)

#1
04/07/2004 (7:35 am)
Modify the gravity when in water?
#2
04/07/2004 (11:57 am)
Make the movement code conditional, I suppose... if(inWater()) { } else { // Not in water, do normal code. }
#3
04/07/2004 (12:03 pm)
You can probably test collision between the player mesh and the water. If they collide, or if they collide a certain amount (i.e. above waist height), begin a swimming animation, and tweak the player position (keeping the player slightly submerged as if he/she is really swimming).

I don't know how to implement any of this, but it's a start.
#4
04/07/2004 (1:30 pm)
I can do the movement conditions easy enough.

The problem is, i dont know how to do the movement right.
Needs to swim where the player is looking, I dont think Im quite skilled enough to work it out and was wondering if anyone has done it or can do it.
#5
04/07/2004 (1:54 pm)
Luke

Hello? Modifying the individual gravity works.
I think there already is a function for when the player is down 50 % into the water, because then "movementinwater" or whatever is called, and you can set the player to move slowly.

Well, if you put the gravity change in there, you will get a Quakeish swim style.
#6
04/07/2004 (2:37 pm)
Have you tried it that way?
if( mWaterCoverage >= 0.9 )
works as the condition.
And I've already halved the player speed in water.
It dosnt seem like a gravity reducement would really allow the player to swim in *all* directions faced. i.e. look up and press forward to swim up.
I could make a function where if you press a swim up/down button you go up or down on the Z axis, but thats not really the same as forward + look up = move up on Z.
#7
04/08/2004 (8:02 pm)
So you've implemented the gravity change when the player is partially submerged in the water. This allows the player to swim forward and backward, and turn left and right, all at the same "height" in the water.

If you want the player to be able to swim up or down in the water, perhaps you can increase the gravity as the player tries to move down, or decrease the gravity as the player tries to move up. You could somehow tie this into a velocity variable so you end up with smooth movement.

Just some suggestions. Again, I don't know how to implement it.
#8
04/08/2004 (8:03 pm)
And I still hope you use a swimming animation when all is said and done. :)
#9
04/08/2004 (8:56 pm)
Why not just accelerate the player along the getMuzzleVector()? No need to change the 'gravity'. You could also change the x-axis rotation (I think), to make the animation swim up and down.
#10
04/08/2004 (9:08 pm)
Yeah, or that...

:)
#11
04/08/2004 (9:20 pm)
The player class already has a density value, just set this to less then 1.0, and the player will float. You will then need to create some water movment code. You could start by copying the walking code and make it so you can "walk on water". Then just make some swim animations.
#12
04/09/2004 (1:46 am)
I'll give Dylan's idea a try...
#13
04/09/2004 (1:49 am)
Theres an idea, might see if i can get the player to move like a flying vehicle.
Any ideas on that?
#14
04/09/2004 (3:59 pm)
I know this isn't totally related, but has anyone gotten the water to actually push the player in a specific direction (ala quake)?

I've figured out how to change the direction of the waves and their amplitude, but that doesn't affect the objects (players, etc.) that are in the water. :(
#15
06/30/2004 (11:08 am)
I tried to find that "movementInWater" method (or something similar), but I haven't been able to... does someone know the correct name of this method (and its location?)

Thanks!