Hi I have written this code to try to simulate my cube killing the sphere.
I've set it so if I press space bar and the sphere and cube are touching it should decrease the spheres health by 1.
When I attack it crashes telling me object 3 does not exist when it is right there(the sphere) :S
Anyway here is my code..
#CONSTANT onep 1
enemyahp = 3
SET DISPLAY MODE 800,600,32
AUTOCAM OFF
MAKE OBJECT CUBE onep,3
COLOR OBJECT onep,RGB(0,255,0)
MAKE OBJECT SPHERE 3, 3
POSITION OBJECT 3, 20,0,0
MAKE OBJECT PLAIN 2,300,300
COLOR OBJECT 2,RGB(0,0,255)
POSITION OBJECT 2,0,-30,0
XROTATE OBJECT 2,-90
SET OBJECT COLLISION ON 1
SET OBJECT COLLISION ON 3
POSITION OBJECT 3, 20,0,0
do
TEXT 20,20,str$(enemyahp)
If keystate(57)=1 AND OBJECT COLLISION (1,3)
DEC enemyahp, 1
ENDIF
IF enemyahp=0 AND OBJECT EXIST(3)=1 THEN DELETE OBJECT 3
position camera object position x(1),object position y(1)+4,object position z(1)
set camera to object orientation 1
move camera -12
if upkey() = 1 then move object 1, .05
if downkey()=1 then move object 1, -.05
if leftkey() = 1 then yrotate object 1, (object angle y(1) - 0.1)
if rightkey() = 1 then yrotate object 1, (object angle y(1) + 0.1)
sync
loop
Thanks for any help