Buoyancy is really fake physics the water is generally a plane here is a function i created a while back to experiment with various Buoyancy parameters
Rem Project: Buoyancy
Rem Created: 10/29/2006 12:33:25 PM
sync on
sync rate 60
Phy Start
phy set gravity 0,-9.8,0
randomize timer()
autocam off
GLOBAL Balloon = 1
make object sphere Balloon,2.0,30,30
position object balloon, 0,5,0
scale object balloon, 80,100,100
phy make rigid body dynamic sphere balloon
PHY Set rigid body gravity balloon, 1.0
phy set rigid body mass balloon ,10.0
GLOBAL Crate = 2
make object box Crate,2.0,4.5,2.0
position object Crate, 3,8,0
phy make rigid body dynamic box Crate
PHY Set rigid body gravity Crate, 1.0
phy set rigid body mass Crate ,10.0
for MoreCrates = 3 to 29
instance object MoreCrates,Crate
position object MoreCrates, rnd(10),rnd(10),rnd(10)
phy make rigid body dynamic box MoreCrates
PHY Set rigid body gravity MoreCrates, 1.0
phy set rigid body mass MoreCrates ,10.0
phy set rigid body angular momentum MoreCrates, (rnd(10)-5)*5.2, (rnd(10)-5)*5.2, (rnd(10)-5)*5.2
next MoreCrates
GLOBAL water_Level = 30
make object plain water_Level, 200,200
position object water_Level, 0,0,0
rotate object water_Level, 90,0,0
color object water_Level,RGB(128,255,255)
ghost object on water_Level
GLOBAL waterlevelangle#
position camera 0, 0,4.5,-10
point camera 0,Object Position x(Balloon),Object Position y(Balloon),Object Position z(Balloon)
do
control camera using arrowkeys 0,.1,1
Buoyancy(balloon, 1.0)
for Crates = 3 to 29
Buoyancy(Crates, .5)
next Crates
phy update
sync
loop
Function Buoyancy(ObjID, Level)
rem create a boyancy force effect below waterline
waterlevelangle#=wrapvalue(waterlevelangle#+1.0)
waterlevel#=cos(waterlevelangle#)
rem boyancy force
forcex#=0.0
forcey#=0.0
forcez#=0.0
mass#=phy get rigid body mass(objid)
if object position y(objid)<Level
forcey#=(abs(object position y(objid))*mass#)/2.0
phy set rigid body angular damping objid,0.1+abs(object position y(objid)/2.0)
phy set rigid body linear damping objid,0.1+abs(object position y(objid)*4)
endif
rem small water/wave influences
if object position y(objid)<waterlevel#
forcey#=forcey#+(rnd(1000)/100.0)*(mass#/200.0)
endif
phy add rigid body force objid,forcex#,forcey#,forcez#,1
Endfunction
Hope this helps
Codger
System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem