Buoyancy

Blitz3D Forums/Blitz3D Beginners Area/Buoyancy

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

If CUBEY#<WATERLEVEL
TranslateEntity CUBE,0,-(GRAVITY*DENSITY*CUBEVOLUME),0
endif

You need something to reduce the bob, which is why it goes forever.

I would have done it something like:

'if entity is not in the water set:
     TimeFromfirstHit#=1.0

'else if entity is in the water,  for each loop/timeperiod set:
     TimeFromfirstHit#=TimeFromfirstHit#*0.8 '(the closer to 1.0 the slower to stop bobbing)
     if TimeFromfirstHit#<0.0001 TimeFromfirstHit#=0.0  '<-infinity catcher


TranslateEntity CUBE,0, -(GRAVITY*DENSITY*CUBEVOLUME)*TimeFromfirstHit#,0


Stevies way above looks good too.