Ok, I got an enemy(ID : 100), and the player (ID : 1)
I made the enemy spawn in a random location, now to the problem : How do I make the enemy move towards the player? No matter where the player might be.
If I'm not totally mistaken, I have to put the movement command in the main loop to make the enemy move at all times?
My code so far :
set display mode 800, 600, 32
autocam off
sync on : sync rate 60
hide mouse
`variables
EnemyHP = 1000
life = 100
score = 0
load image "Datasky.JPG", 1
`Setup camera
position camera 30, 30, 30 : point camera 0, 0, 0
`Make player
make object sphere 1, 30
`Make skybox
set camera range 1, 6000
make object cube 999, -5000
texture object 999, 1
`creates the shooting range limb
make object sphere 99, 30
make mesh from object 1, 99
delete object 99
add limb 1, 1, 1
offset limb 1,1,0,0,5000
hide limb 1, 1
`Makes enemies
makeenemy(100)
position object 100, rnd(4000), rnd(4000), rnd(4000)
make light 1
position light 1, 0, 0, 0
set light range 1, 7000
do
position camera object position x(1), object position y(1), object position z(1)
camy#=camy#+mousemovex()*.1
camx#=camx#+mousemovey()*.1
if camx>90 and camx#<135 then camx#=90
if camx>270 and camx#<225 then camx#=90
yrotate camera camy#
xrotate camera camx#
yrotate object 1, camy#
xrotate object 1, camx#
if upkey()=1 then move object 1, 1
sync
loop
function makeenemy(OBJECT)
make object sphere object, 15
endfunction makeenemy
function shootenemy(OBJECT)
if mouseclick()=1
endif
if object exist(OBJECT)=1
if intersect object (OBJECT, 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
dec EnemyHP#, 1
endif
endif
endfunction shootenemy
If you find any other errors or bad structure, point that out to if you wish.