I modified the force to apply it correctly in the direction the camera is aimed.
Added a rug from the cloth demos ( any image will do)
phy start
autocam off
sync on
sync rate 60
color backdrop RGB(128,255,255)
position camera 0, 20, -70
make light 1
set directional light 1, -5, -5, 5
set ambient light 40
make object box 1, 150, 1, 150
phy make rigid body static box 1
color object 1, RGB(0,0,0)
temp = make vector3(1)
` attachement box for the cloth
make object box 5, 6, 0.5, 0.5
position object 5, -7.5, 10, 5
color object 5,rgb(0,0,255)
phy make rigid body static box 5
` create the cloth'
load image "rug512.bmp",33
phy make cloth 3
phy set cloth dimensions 3, 5, 9.5, 0.4
phy set cloth position 3, -5, 10, 5
phy set cloth rotation 3, 90, 0, 180
phy set cloth friction 3, 0.5
phy set cloth tearing 3, 1
phy set cloth tear factor 3, 2.0
phy build cloth 3
phy attach cloth to shape 3, 5, 0
color object 3,rgb(100,100,255)
texture object 3,33
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, 2.0, 2.5, 2.0, 1, 1.5, 45.0
hide object 2
for i = 2 to 31
if object exist ( i ) and i <> 3
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
texture object 1, 33
make camera 2
position camera 2, 0,5,-30
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
EndFunction
Function Pusher(CC)
while phy get collision data() <> 0
a =PHY GET COLLISION OBJECT A ()
b =PHY GET COLLISION OBJECT B ()
if a = CC and b <> 1
color object b, rgb ( 255, 0, 0 )
push(b)
endif
if a <> 1 and b = cc
color object a, rgb ( 255, 0, 0 )
push(a)
endif
endwhile
SET CAMERA TO OBJECT ORIENTATION 0,CC
XL# =object position x(CC):YL# =object position Y(CC):ZL# =object position z(CC)
XA# = object angle X(CC):YA# = object angle Y(CC):ZA# = object angle Z(CC)
position camera 0, XL#,YL#,ZL#
Endfunction
Function Push(target)
' temp = make vector3(1) rem this needs to be moved to start of program
oldx# = camera position x()
oldy# = camera position y()
oldz# = camera position z()
move camera 1
set vector3 1,camera position x()-oldx#,camera position y()-oldy#,camera position z()-oldz#
normalize vector3 1,1
move camera -1
force# = 500
phy add rigid body force target,x vector3(1)*force#,y vector3(1)*force#,z vector3(1)*force#,3
Endfunction
System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem