Gah, I'm trying to make the entity turn so that it 'aims' at an player (the origin)
>_<
This is what I have, and it seems to work pretty well right now
Note: I got this from the plugin Sentry Gun
Code:
sentry_turntotarget(ent, Float:sentryOrigin[3], target, Float:closestOrigin[3]) {
if (target) {
new name[32]
get_user_name(target, name, 31)
new Float:newAngle[3]
entity_get_vector(ent, EV_VEC_angles, newAngle)
new Float:x = closestOrigin[0] - sentryOrigin[0]
new Float:z = closestOrigin[1] - sentryOrigin[1]
new Float:radians = floatatan(z/x, radian)
newAngle[1] = radians * (180 / 3.14)
if (closestOrigin[0] < sentryOrigin[0])
newAngle[1] -= 180.0
entity_set_vector(ent, EV_VEC_angles, newAngle)
}
}
But it faces the opposite direction, all the time.
__________________