I found coggers usefull code, for moveing dynamic objects, but i notiaced that objects would not move for some reason sometimes, and the boxes reacted unrealisticly. So it suddenly sprang to my mind that none of the mathematical stuff is needed (Applying forces to colliding objects etc). Instead, I have used the kinematic objects to the advantage. I create a kenematic object which is slightly bigger than the character controller and update its position to be the same as the character contorller. Here is the code (It is an edited version of coggers code, no Pusher function)
phy start
autocam off
sync on
sync rate 60
color backdrop 0
position camera 0, 20, -70
make light 1
set directional light 1, -5, -5, 5
temp = make vector3(1) rem this needs to be moved to start of program
make object box 1, 150, 1, 150
phy make rigid body static box 1
x# = 10
y# = 1
for i = 10 to 20
make object box i, 3, 2, 10
position object i, x#, y#, 0
x# = x# + 3
y# = y# + 1
phy make rigid body static box i
next i
y# = 1
for i = 21 to 31
make object cube i, 2
position object i, -10, y#, 0
y# = y# + 2
phy make rigid body dynamic box i
next i
make object box 2,3.0,3.0,3.0
phy make box character controller 2, 0, 6, 0, 1, 2.5, 1, 1, 1.5, 45.0
hide object 2
`Create kenimatic object
make object box 100,4.5,5,4.5
phy make rigid body dynamic box 100
phy set rigid body kinematic 100, 1
for i = 1 to 20
if object exist ( i )
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
endif
next i
make camera 2
position camera 2, 0,5,-50
point camera 2, object position x (2), object position y (2), object position z (2)
set camera view 2,400,10,600,210
do
MoveChararacter(2)
` Pusher(2)
point camera 2, object position x (2), object position y (2), object position z (2)
phy update
sync
loop
Function MoveChararacter(CH)
if leftkey ( )
turn object left CH, 1.0
endif
if rightkey ( )
turn object right CH, 1.0
endif
if upkey ( )
phy move character controller CH, 10.0
else
if downkey()
phy move character controller CH, -10.0
else
phy move character controller CH, 0.0
endif
endif
SET CAMERA TO OBJECT ORIENTATION 0,CH
XL# =object position x(CH):YL# =object position Y(CH):ZL# =object position z(CH)
XA# = object angle X(CH):YA# = object angle Y(CH):ZA# = object angle Z(CH)
position camera 0, XL#,YL#,ZL#
phy set rigid body position 100, object position x(CH), Object position y(CH), object position z(CH)
phy set rigid body rotation 100, object angle x(CH), Object angle y(CH), object angle z(CH)
EndFunction
The main advantage of doing it this way, is that anything in DP will react with it (Ragdolls, Cloth, Dynamic particles etc)
Hope this is usefull
General Reed
AMD Athlon 64 3200+, 1GB ram, Geforce 6600 GTX, 80GB HDD
Vist www.scratchyrice-dev.co.uk