Well, the one that the enemies turn towards the target...
I made a quick snippet:
sync on : hide mouse : sync rate 60
`make object that "looks"
make object box 1,1,1,10
position object 1,50,0,50
`set object fov
objectfov# = 20.0
do
`get player position
posx# = camera position x()
posz# = camera position z()
angy# = camera angle y()
`control camera
if upkey() = 1
posx# = newxvalue(posx#,angy#,1)
posz# = newzvalue(posz#,angy#,1)
endif
if leftkey() = 1 then yrotate camera wrapvalue(angy# - 2)
if rightkey() = 1 then yrotate camera wrapvalue(angy# + 2)
`detect the angle between the player and the looking object
diff_angle# = atanfull( object position x(1) - posx#, object position z(1) - posz# )
if wrapvalue(object angle y(1) - diff_angle#) < 180 + (objectfov#/2)
if wrapvalue(object angle y(1) - diff_angle#) > 180 - (objectfov#/2)
viewed = 1
else
viewed = 0
endif
endif
text 5,5,str$(wrapvalue(object angle y(1) - diff_angle#))
`show the object is looking at you or not
if viewed = 1 then color object 1,rgb(255,0,0) else color object 1,rgb(0,255,0)
`rotate the object
yrotate object 1,wrapvalue(object angle y(1) - 0.2)
`update camera
position camera posx#,posy#,posz#
sync
loop
`detect the angle between the player and the looking object
diff_angle# = atanfull( object position x(1) - posx#, object position z(1) - posz# )
if wrapvalue(object angle y(1) - diff_angle#) < 180 + (objectfov#/2)
if wrapvalue(object angle y(1) - diff_angle#) > 180 - (objectfov#/2)
viewed = 1
else
viewed = 0
endif
endif
is the most important part.
Immunity and Annihalation makes Immunihalation...