I've been trying to fix this for hours, and I just can't get it working. What I want is that object 1 shouldn't be able to go through object 100. Also, the camera should follow object 1's position. What am I doing wrong? =(
Here's my code:
Sync On
Sync Rate 30
Hide mouse
Backdrop on
Set camera range 1,5000
Fog on
Fog distance 4000
Fog color RGB(128,128,128)
Color Backdrop RGB(128,128,128)
Rem make matrix
Make matrix 1,10000,10000,20,20
Rem texture matrix
Load image "grass09.bmp",1
Prepare matrix texture 1,1,1,1
Fill matrix 1,0,1
rem Randomize the matrix
randomize matrix 1,125
X#=10000
Z#=8785
//Map
Load Object "Aliens Vs Humans.x",100
Position Object 100,10000,10120,8800
SC_SetupObject 100,0,0
Load Image "hk53_n.bmp",4219
//Character
Make Object Sphere 1,25
Position Object 1,10000,10195,8785
SC_SetupObject 1,0,0
//HIDE Object 1
//Gun
Load Object "hk53_n.3ds",101
Texture Object 101,4219
//Bottom collision
Make Object sphere 10,1
MAKE MESH FROM OBJECT 1,10
DELETE OBJECT 10
ADD LIMB 1,1,1
OFFSET LIMB 1,1,0,1,0
HIDE LIMB 1,1
xrotate object 101,-10
yrotate object 101,4
zrotate object 101,2
LOCK#=0
Position Camera 10000,10195,8785
Lock Object On 101
position object 101,0,-15,15
Do
Text 100,100,"X: " + str$(Object Position X(1)) + " Y: " + str$(Object Position Y(1)) + " Z: " + str$(Object Position Z(1))
Text 300,300,"X: " + str$(Camera Position X()) + " Y: " + str$(Camera Position Y()) + " Z: " + str$(Camera Position Z())
//Cursor
//paste image cursor,mousex()-100,mousey()-100,1
//position object 101, camera position x(),camera position y() - 15,camera position z() + 15
//position object 101, camera position x(),camera position y() - 15,camera position z() + 15
//IF LOCK#=0
//Lock Object On 101
LOCK#=1
//ENDIF
yrotate camera camera angle y()+mousemovex()
xrotate camera camera angle x()+mousemovey()
//position camera object position x(1),object position y(1),object position z(1)
//Control camera
if keystate(17) = 1
x# = newxvalue(x#, camera angle y(), 8)
z# = newzvalue(z#, camera angle y(), 8)
endif
if keystate(31) = 1
x# = newxvalue(x#, camera angle y() + 180, 8)
z# = newzvalue(z#, camera angle y() + 180, 8)
endif
if keystate(30) = 1
x# = newxvalue(x#, camera angle y() - 90, 8)
z# = newzvalue(z#, camera angle y() - 90, 8)
endif
if keystate(32) = 1
x# = newxvalue(x#, camera angle y() + 90, 8)
z# = newzvalue(z#, camera angle y() + 90, 8)
endif
OX# = OBJECT POSITION X(1)
OY# = OBJECT POSITION Y(1)
OZ# = OBJECT POSITION Z(1)
position object 1,x#,camera position y(),z#
XX# = OBJECT POSITION X(1)
YY# = OBJECT POSITION Y(1)
ZZ# = OBJECT POSITION Z(1)
SlidingCollision(OX#,OY#,OZ#,XX#,YY#,ZZ#,10,1,100)
X2# = OBJECT POSITION X(1)
Y2# = OBJECT POSITION Y(1)
Z2# = OBJECT POSITION Z(1)
//C = sc_SphereSlide(100,OX#,OY#,OZ#,XX#,YY#,ZZ#,10,1)
//IF C > 0
IF XX = X2 AND YY = Y2 AND ZZ = Z2
position camera x#,camera position y(),z#
ENDIF
//Gravity
IF INTERSECT OBJECT (100, LIMB POSITION X(1,1), LIMB POSITION Y(1,1), LIMB POSITION Z(1,1), OBJECT POSITION X(1),OBJECT POSITION Y(1), OBJECT POSITION Z(1)) < 1
IF JUMPING#=0
POSITION OBJECT 1,OBJECT POSITION X(1),OBJECT POSITION Y(1) - SPEED#,OBJECT POSITION Z(1)
ENDIF
ENDIF
//End of gravity
//Jumping
//IF UPKEY()=1 AND JUMPING#=0
//IF INTERSECT OBJECT (5492, LIMB POSITION X(2000,1), LIMB POSITION Y(2000,1), LIMB POSITION Z(2000,1), OBJECT POSITION X(2000),OBJECT POSITION Y(2000), OBJECT POSITION Z(2000))>0
//JUMP#=1
//ENDIF
//ENDIF
IF JUMP#=1
JUMP_SPEED#=2:JUMPING#=1:JUMP#=0
ENDIF
IF JUMPING#=1
DEC JUMP_SPEED#,.015
POSITION OBJECT 1,OBJECT POSITION X(1),OBJECT POSITION Y(1)+JUMP_SPEED#, OBJECT POSITION Z(1)
IF INTERSECT OBJECT (100, LIMB POSITION X(1,1), LIMB POSITION Y(1,1), LIMB POSITION Z(1,1), OBJECT POSITION X(1),OBJECT POSITION Y(1), OBJECT POSITION Z(1))>0 THEN JUMPING#=0
ENDIF
Sync
Loop
FUNCTION SlidingCollision(X1#,Y1#,Z1#,X2#,Y2#,Z2#,Radius#,Dyn,Obj)
C = sc_SphereSlide(Obj,X1#,Y1#,Z1#,X2#,Y2#,Z2#,Radius#,Dyn)
IF C > 0
cx# = sc_getCollisionSlideX()
cy# = sc_getCollisionSlideY()
cz# = sc_getCollisionSlideZ()
POSITION OBJECT Dyn, cx#, cy#, cz#
ENDIF
ENDFUNCTION
P.S I'm using sparkys collision ,dll
Thanks in advance! :p