Game Development Community

swimming?

by Very Interactive Person · in Torque Game Engine · 08/27/2001 (4:47 am) · 1 replies

how could i make it so the player swims under water? so he could swim up and down .... and if he is standing still to long, sinks to the bottom. Now the player just walks on and has a different jump/walk speed under water... but that's a bit unrealistic in my opnion.
I have no idea how to start here.... so please help me out.

#1
08/27/2001 (5:46 am)
I did a little quick hack to add something like this...

in server/scripts/player.cs:
Around line 909, in function Armor::onEnterLiquid
add %data.jumpDelay = 0; %data.jumpForce = 1.5 * 90;

Around line 930, in function Armor::onLeaveLiquid
add %data.jumpDelay = 15; %data.jumpForce = 8.3 * 90;

This makes it impossible to jump in water due to the lack of surface contact underwater... to work around this you need to go to 'game/player.cc' and around line 1844 in the function Player::canJump() add an 'if (inLiquid) return true;' before the other more sophisticated anti-swimming anti-jumpjet code :p

The only downsides to this are:
(a)the inability to turn/change velocities while "swimming".. changing this would either mean you have to add the ability to turn in air (while it was always fun in Quake, its just a little unrealistic :p) or add more code that would make this less of a quick hack :p
(b)the jump animation keeps playing while "swimming":
doesn't look too bad really, just isn't swimming persay
(c)warping effects when jumping out of the water:
this could be fixed by changing some variables depending on the "coverage" (how much water you have over your head..)
(d)probably a few other things I didnt notice in the 30 seconds I tested it

Thanks to Josh Dammeier for some of the above, namely the jumpForce for swimming, that I borrowed from his jumpjet-like behavior tutorial (v12.ultimategroup.com <-free plug)

nohbdy