phy start
autocam off
sync on
`sync rate 60
color backdrop 0
position camera 0, 220, 0
point camera 0,0,0
phy set gravity 0,0,0
hide mouse
spheres=120
for t = 2 to spheres
make object sphere t, 2
position object t, rnd(400)-200, rnd(400)-200, rnd(400)-200
phy make rigid body dynamic sphere t
next t
for i = 2 to spheres
color object i, rgb ( rnd ( 255 ), rnd ( 255 ), rnd ( 255 ) )
set object specular i, rgb ( rnd ( 255 ), rnd ( 255 ), rnd ( 255 ) )
set object specular power i, 255
set object ambient i, 0
next i
distv=1
global force as float
null=make vector3(distv)
endtime=timer()+20000
gravity=1
do
if endtime<=timer()
if gravity=1
endtime=timer()+450
gravity=2
endif
if gravity=0
endtime=timer()+80000
gravity=1
endif
if gravity=2 then gravity=0
endif
if gravity=1
for t = 2 to spheres
if object position x(t)>200 or object position x(t)<-200 then respawnobj(t)
if object position y(t)>200 or object position y(t)<-200 then respawnobj(t)
if object position z(t)>200 or object position z(t)<-200 then respawnobj(t)
for s = 2 to spheres
if s<>t
set vector3 distv,object position x(t)-object position x(s),object position y(t)-object position y(s),object position z(t)-object position z(s)
slv=squared length vector3(distv)
normalize vector3 distv,distv
force=-(250.0*250)/slv
phy add rigid body force t, x vector3(distv)*force, y vector3(distv)*force, z vector3(distv)*force, 0
endif
next s
next t
endif
phy update
sync
loop
function respawnobj(x)
delete object x
make object sphere x,2
position object x, rnd(400)-200, rnd(400)-200, rnd(400)-200
color object x,rgb(rnd(255),rnd(255),rnd(255))
set object specular x, rgb ( rnd ( 255 ), rnd ( 255 ), rnd ( 255 ) )
set object specular power x, 255
set object ambient x, 0
phy make rigid body dynamic sphere x
endfunction
what should happen is that after each explosion, the object sfly out, and any that go out of bounds respawn in the center.
however, once this happens, they dont start moving again.
why's this?