this will find out who you are pointing at, it's really simple.... read the bit at the top to find out how....
it's maybe not the ost proffetional way of doing it, but it works pretty well.
`this will find out who you are pointing at....
`its pretty simple...say you make 4 enemies, each enemy has a cube..
`the cubes are positioned at the camera and hidden, they each point to an enemy...
`if the camera's angle is roughly the same as one of the cubes then that would
`mean that you are pointing at one of the enemies, then it simple tells you who.....
`i just put it on the forums coz i thought it would be usefull, you can
`use it from free, i dont need any credit :)
`setup
sync on
sync rate 0
hide mouse
`stuff
set camera range 1,8000
make object plain 1,1,1
position object 1,0,0,60
lock object on 1
disable object zdepth 1
`create enemies
make object cube 2,100
position object 2,500,50,0
make object cube 3,100
position object 3,500,50,500
make object cube 4,100
position object 4,50,50,0
make object cube 5,100
position object 5,5000,50,50
color object 2,rgb(255,0,255)
color object 3,rgb(255,0,255)
color object 4,rgb(255,0,255)
color object 5,rgb(255,0,255)
`each enemy has a little object
make object cube 6,1
make object cube 7,1
make object cube 8,1
make object cube 9,1
hide object 6
hide object 7
hide object 8
hide object 9
`main loop
do
`some controls
position mouse 320,240
cx#=wrapvalue(cx#+mousemovey())
cy#=wrapvalue(cy#+mousemovex())
rotate camera cx#,cy#,0
if mouseclick()=1 then move camera 5
if mouseclick()=2 then move camera -5
`here, we position the cubes at the camera
for c=6 to 9
position object c,camera position x(),camera position y(),camera position z()
next c
`point each cube to each enemy
point object 6,object position x(2),object position y(2),object position z(2)
point object 7,object position x(3),object position y(3),object position z(3)
point object 8,object position x(4),object position y(4),object position z(4)
point object 9,object position x(5),object position y(5),object position z(5)
`if the camera angle is roughly the same as the cube.....
if camera angle y()>object angle y(6)-10
if camera angle y()<object angle y(6)+10
if camera angle x()>object angle x(6)-10
if camera angle x()<object angle x(6)+10
obj=2
endif
endif
endif
endif
if camera angle y()>object angle y(7)-10
if camera angle y()<object angle y(7)+10
if camera angle x()>object angle x(7)-10
if camera angle x()<object angle x(7)+10
obj=3
endif
endif
endif
endif
if camera angle y()>object angle y(8)-10
if camera angle y()<object angle y(8)+10
if camera angle x()>object angle x(8)-10
if camera angle x()<object angle x(8)+10
obj=4
endif
endif
endif
endif
if camera angle y()>object angle y(9)-10
if camera angle y()<object angle y(9)+10
if camera angle x()>object angle x(9)-10
if camera angle x()<object angle x(9)+10
obj=5
endif
endif
endif
endif
`tell player who you're pointing at!
ink rgb(255,0,0),0
if obj=2 then center text object screen x(2),object screen y(2)-60,"Enemy 1"
if obj=3 then center text object screen x(3),object screen y(3)-60,"Enemy 2"
if obj=4 then center text object screen x(4),object screen y(4)-60,"Enemy 3"
if obj=5 then center text object screen x(5),object screen y(5)-60,"Enemy 4"
`end loop
sync
loop
"Well, if he dies, it'll teach him not to do it again." - Me