ignore the question, I got another question. I made a code, that the enemy can see the player, follow him, and attack, but when the enemy is near the play, it doesen't stop moving, what should I do?
Here is the Code:
sync on
sync rate 60
hide mouse
autocam off
ai start
make object box 1, 5, 2.5, 5
load object "monster-animated-character-X.x", 2
scale object 2, 15, 15, 15
position object 2, 50, 0, 50
make object box 3, 15, 2.5, 5
position object 3, 25, 0, 25
ai add static obstacle 3
position camera 0, 15, 0
ai add enemy 2
ai set entity stance 2, 1
ai set entity view arc 2, 90, 180
ai set entity view range 2, 100
ai set entity speed 2, 10.0
ai set entity attack distance 2, 3
ai set entity fire arc 2, 1
ai debug show paths 0
ai debug show waypoint edges 0, 0
ai debug show waypoints 0, 0
set object speed 2, 25
ai add player 1, 1
do
Move()
Camera()
Stats()
position object 2, ai get entity x(2), 0, ai get entity z(2)
ai entity look at position 2, ai get entity destination x(2), ai get entity destination z(2)
rotate object 2, object angle x(2), ai get entity angle y(2), object angle z(2)
target = ai get entity target id(2, 1)
if target = 1 then point object 2, object position x(1), 0, object position z(1)
if ai get entity can fire(2)=1
x# = object position x(2)
z# = object position z(2)
ax# = object angle x(2)
az# = object angle z(2)
position object 2, x#, 0, z#
rotate object 2, ax#, ai get entity angle y(2), az#
play object 2, 250, 330
endif
ai update
sync
loop
function DistTarget(object)
Dist# = sqrt((object position x(1) - object position x(object)) + (object position y(1) - object position y(1)) + (object position z(1) - object position z(object))^2)
endfunction Dist#
function Stats()
text 0, 0, "FPS: "+str$(screen fps())
text 0, 10, "Ai: "+ ai get entity action$(2)
endfunction
function Move()
if keystate(17)=1
XAngle# = object angle x(1)
xrotate object 1, 0
move object 1, .5
xrotate object 1, XAngle#
endif
if keystate(31)=1
XAngle# = object angle x(1)
xrotate object 1, 0
move object 1, -.5
xrotate object 1, XAngle#
endif
if keystate(30)=1 then move object left 1, .5
if keystate(32)=1 then move object right 1, .5
endfunction
function Camera()
position camera object position x(1), object position y(1)+5, object position z(1)
rotate camera camera angle x(0)+(mousemovey()/4.0),camera angle y(0)+(mousemovex()/4.0), 0
rotate object 1, camera angle x(0)+(mousemovey()/4.0), camera angle y(0)+(mousemovex()/4.0), 0
endfunction
Windows XP,pentium IV, 3.0 MGZ, 1024 mb memory, 256 mb ATI Radeon PCIE X700 Pro 'sett squadron back on the assault'