Game Development Community

dev|Pro Game Development Curriculum

Re-enable buoyancy from T3D 1.0

by Glenn Bermingham · 08/21/2013 (9:22 am) · 4 comments

I wanted to re-implement the buoyancy that used to be on by default in T3D, searched for ages and finally found the one line that does it and thought I'd share.

In Source / Engine / T3D / Player.cpp

Then search for below, un-comment it (Around line 3168)
//mVelocity.z -= buoyancyForce;
to
mVelocity.z -= buoyancyForce;

Build the DLL and you're done.

You can edit the values in the water block/plane within the mission editor to change the effect. You can also edit the values in art/datablocks/player.cs "density = 1.1;".

#1
08/21/2013 (9:30 am)
Just to clarify, this is only for physX/bullet right?
#2
08/21/2013 (10:19 pm)
Lukas, yes.... I believe this is only applicable for PhysX and Bullet enabled builds. Basically, Glenn re-exposed a snip of code that was specific to those features. I could be wrong of course but, I have been doing a TON of PhysX work lately and it matches the other buoyancy commands.

There is a decent doc on all of that stuff here:

docs.garagegames.com/torque-3d/reference/group__Physics.html

Ron
#3
08/26/2013 (6:39 am)
"Just to clarify, this is only for physX/bullet right?"

it works without physX/bullet.

TO SEE THE EFFECT EASILY,DROP PLAYER ON WATER AND SET IT'S DENSITY TO a Small VALUE LIKE 0.2
or
FOR WATERPLANE OR BLOCK JUST CHANGE DENSITY(FROM WATER OBJECT'S PROPERTIES) TO a HIGHER VALUE.
u will be thrown to sky.
#4
04/12/2015 (11:17 am)
has anyone played with this to see if set values limit how far an object will sink?

I ask as I wonder if possible to have floating containers just under the surface?