Whenever I move the sphere object into one of the boxes, the collision seems to be detected in the center of the sphere, not the polygons of it. Can anyone tell me how to fix this?
`%ProjectTitle%
`======================
`?Author%
`======================
`Main Source File
Rem Setup sync
Sync On
Sync Rate 30
Rem Make Cubes and place randomly
For x = 1 to 5
Make object cube x,100
Position object x,Rnd(2000),0,Rnd(2000)
setUpObject x,0,0
Next x
Rem Make sphere
Make object sphere 10,50
setUpObject 10,1,0
rem make a white image, since coloring doesn't work very well with no light
make memblock 1,16
write memblock dword 1,0,1
write memblock dword 1,4,1
write memblock dword 1,8,32
write memblock dword 1,12,rgb(255,255,255)
make image from memblock 1,1
delete memblock 1
Rem Main loop
Do
Rem Store Object angle Y in aY#
aY# = Object angle Y(10)
oldX#=object position x(10)
oldY#=object position y(10)
oldZ#=object position z(10)
Rem Control input for camera
If Upkey()=1 then Move object 10,10
If Leftkey()=1 then Yrotate object 10,Wrapvalue(aY#-5)
If Rightkey()=1 then Yrotate object 10,Wrapvalue(aY#+5)
Rem get player object position and store in X# and Z#
X# = Object position x(10)
Z# = Object position z(10)
Y#=object position y(10)
collide=intersectObject(0,0,oldX#,oldY#,oldZ#,X#,Y#,Z#,0)
if collide>0
X#=oldX#
Y#=oldY#
Z#=oldZ#
position object 10,X#,Y#,Z#
endif
Rem get new camera position and store in cZ# and cX#
cZ# = Newzvalue(Z#,aY#-180,100)
cX# = Newxvalue(X#,aY#-180,100)
Rem position camera
Position Camera cX#,100,cZ#
Rem point the camera at the player object
Point camera X#,50,Z#
Rem Refresh Screen
Sync
Loop
end
delete memblock 10