this sort of works. rem back in what I have rem out to make it work on my system.
sync on : sync rate 60
SET DISPLAY MODE 1024,768,32
autocam off
global objnum = 6
global ammoID = 5000
global count = 0
global count1 = 0
`load image "fire.png",1
phy start
PHY ENABLE DEBUG
phy set gravity 0,-200,0
holds = 0
`Load object "sketty.x",1
make object box 1,100,1,100
position object 1,0,-5,0
phy make rigid body static mesh 1
`Sc_setupcomplexobject 1,2,2
`Charecter setup
make object sphere 2,4
position object 2,-10,-1,12
hide object 2
`sc_setupobject 2,1,0
make object sphere 3,10
phy make rigid body dynamic sphere 3
phy make material 3, "no bounce"
phy set material restitution 3, 0.0
PHY SET MATERIAL DYNAMIC FRICTION 3,1
phy build material 3
do
set cursor 0,0
pick screen mousex(),mousey(),10
position mouse screen width()/2,screen height()/2
`Camera setup
position camera 0,object position x(2),object position y(2)+6,object position z(2)
rotate camera 0,camera angle x(0)+mousemovey()/2.5,object angle y(2),object angle z(2)
if camera angle x(0) >= 85
xrotate camera 0,85
endif
if camera angle x(0) <= -85
xrotate camera 0,-85
endif
oldx# = object position x(2)
oldy# = object position y(2)
oldz# = object position z(2)
`Setup movement
if keystate(17)=1
move object 2,0.5
endif
if keystate(31)=1
move object 2,-0.5
endif
if keystate(30)=1
move object left 2,0.2
endif
if keystate(32)=1
move object right 2,0.2
endif
if spacekey()=1
position object 2,object position x(2),object position y(2)+0.4,object position z(2)
endif
if shiftkey()=1
position object 2,object position x(2),object position y(2)-0.4,object position z(2)
endif
rotate object 2,object angle x(2),object angle y(2)+mousemovex()/2.5,object angle z(2)
x# = object position x(2)
y# = object position y(2)
z# = object position z(2)
` collide = sc_sphereSlideGroup(2,oldx#,oldy#,oldz#,x#,y#,z#,4,0)
` if collide>0
` x# = sc_getCollisionSlideX()
` y# = sc_getCollisionSlideY()
` z# = sc_getCollisionSlideZ()
`endif
position object 2,x#,y#,z#
controlShooting()
if mouseclick()=1 and count1>2
gosub _drag_object
obj1 = pick object (screen width()/2,screen height()/2,5000,ammoID)
count1 = 0
endif
`if mouseclick()=2 and count>2
`gosub _drag_object
`obj2 = pick object (screen width()/2,screen height()/2,5000,ammoID)
`count = 0
`endif
If keystate(33)=1 and count>5
PHY BUILD FIXED JOINT ammoID
phy make fixed joint ammoID,obj1,obj2
inc ammoID,1
endif
if keystate(12)=1 and count>5
input "input you stack integer ",input1#
for i = 1 to input1#
if countbox>10
make object cube ammoID,5
position object ammoID,object position x(2),object position y(2)+offsetboxy#,object position z(2)
phy make rigid body dynamic box ammoID,3
phy set rigid body mass ammoID, 500
PHY SLEEP RIGID BODY ammoID
color object ammoID, rgb ( rnd ( 255 ), rnd ( 255 ), rnd ( 255 ) )
set object specular ammoID, rgb ( rnd ( 255 ), rnd ( 255 ), rnd ( 255 ) )
set object specular power ammoID, 255
set object ambient ammoID,0
inc ammoID,1
inc offsetboxy#,5
endif
next i
offsetboxy# = 0
count = 1
endif
print "object1 = ",obj1
print "object2 = ",obj2
`sc_updateobject 2
`sc_updateobject 1
phy update
inc count,1
inc count1,1
inc countbox,1
sync
loop
phy end
function controlShooting()
if controlkey()=1 and count>5
angy# = camera angle y()
angx# = -camera angle X()
make object cube ammoID,5
position object ammoID,object position x(2),object position y(2),object position z(2)
phy make rigid body dynamic box ammoID,3
phy set rigid body linear velocity ammoID, 50*sin(angy#)*cos(angx#),50*sin(angx#),50*cos(angy#)*cos(angx#)
phy set rigid body mass ammoID, 500
color object ammoID, rgb ( rnd ( 255 ), rnd ( 255 ), rnd ( 255 ) )
set object specular ammoID, rgb ( rnd ( 255 ), rnd ( 255 ), rnd ( 255 ) )
set object specular power ammoID, 255
set object ambient ammoID,0
count = 0
inc ammoID
endif
endfunction
_drag_object:
if mouseclick()=0 then pickmode=0 : cursorobj=0
mclick=mouseclick()
if mclick>0
if pickmode=0
cursorobj=pick object(mousex(),mousey(),5000,ammoID)
if cursorobj>0
pickmode=mclick
pickdistance#=get pick distance()
pickfromx#=get pick vector x()
pickfromy#=get pick vector y()
pickfromz#=get pick vector z()
if pickmode=1
objx#=object position x(cursorobj)
objy#=object position y(cursorobj)
objz#=object position z(cursorobj)
else
objx#=object angle x(cursorobj)
objy#=object angle y(cursorobj)
objz#=object angle z(cursorobj)
pickdiffx#=mousemovey() : pickdiffx#=0
pickdiffy#=mousemovex() : pickdiffy#=0
endif
else
highlightobj=0
endif
endif
if pickmode>0
if pickmode=1
pick screen mousex(),mousey(),pickdistance#
picktox#=get pick vector x()
picktoy#=get pick vector y()
picktoz#=get pick vector z()
pickdiffx#=picktox#-pickfromx#
pickdiffy#=picktoy#-pickfromy#
pickdiffz#=picktoz#-pickfromz#
grid=0
if grid=1
pickdiffx#=int(pickdiffx#/5)*5
pickdiffy#=int(pickdiffy#/5)*5
pickdiffz#=int(pickdiffz#/5)*5
endif
`position object cursorobj,objx#+pickdiffx#,objy#+pickdiffy#,objz#+pickdiffz#
phy set rigid body position cursorobj,objx#+pickdiffx#,objy#+pickdiffy#,objz#+pickdiffz#
else
pickdiffx#=pickdiffx#+mousemovey()
pickdiffy#=pickdiffy#+mousemovex()
grid=0
if grid=1
tpickdiffx#=int(pickdiffx#/22.5)*22.5
tpickdiffy#=int(pickdiffy#/22.5)*22.5
else
tpickdiffx#=pickdiffx#
tpickdiffy#=pickdiffy#
endif
` rotate object cursorobj,wrapvalue(objx#-tpickdiffx#),wrapvalue(objy#-tpickdiffy#),objz#
phy set rigid body rotation cursorobj,wrapvalue(objx#-tpickdiffx#),wrapvalue(objy#-tpickdiffy#),objz#
endif
endif
endif
return
Dark Physics makes any hot drink go cold.