AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   entity vector (https://forums.alliedmods.net/showthread.php?t=45519)

TheNewt 10-04-2006 15:38

entity vector
 
[Edit] After playing around with it a lot I managed to fix and attain what I wanted. And I learned a valuable lesson in how to set entity angles :) [/Edit]


I just don't get this

Code:
entity_set_vector(ent, EV_VEC_angles, origin)

okay so it has the entity, angles, then it gives it the float origin.
Which contains the numbers for the x,y,z axis right?
How does that calculate what angle the entity is at?
O.o
It just seems like there is an extra variable somewhere that I can't see.

Silencer123 10-04-2006 15:57

Re: entity vector
 
I do not know where you got that one from but it seems to be wrong?!
Because that would set an Entities angles by a Float Origin wouldn't it? @_@
For Origin it is:
entity_set_vector(ent, EV_VEC_origin, origin)
Or not?

TheNewt 10-04-2006 16:00

Re: entity vector
 
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.

Silencer123 10-04-2006 16:13

Re: entity vector
 
So you wish entity_set_vector(ent, EV_VEC_angles, origin)
will make the Entity "ent" look at the given Origin? One word: No.
It actually sets the Entities ("ents"'s) angles like defined in last parameter.
The Code you just posted will make an Entity ('ent') look at something ('target').

TheNewt 10-04-2006 16:30

Re: entity vector
 
gah, the initial question was, define how "origin" effects "entity_set_vector(ent, EV_VEC_angles, origin)"
Like if you alter origin[1] what should/would happen to the angles.

stupok 10-04-2006 17:02

Re: entity vector
 
Quote:

Originally Posted by MysticDeath (Post 387536)
But it faces the opposite direction, all the time.

How about not subtracting 180 from newAngle[1]?

TheNewt 10-04-2006 17:25

Re: entity vector
 
after playing around I found out that the first number in the Origin array used int he angles actually alters the entities pitch (looking up and down), the second number alters the rotation (left and right) and the third number is the tilt (leaning left and right)
so the
Code:
if (closestOrigin[0] < sentryOrigin[0])     newAngle[1] -= 180
says that if the closest origin is below the sentry, then move the sentry 180 degrees around. But it seems for some reason to do that when the closestOrigin[1] theoretically becomase less then sentryOrigin[1] O.o
gah, :(

VEN 10-05-2006 00:10

Re: entity vector
 
The whole task can be done quite simple, take a look

Code:
new Float:v1[3], Float:v2[3] pev(id, pev_origin, v1) // origin of the 1st player pev(id2, pev_origin, v2) // origin of the 2nd player xs_vec_sub(v2, v1, v1) // vector 1st->2nd engfunc(EngFunc_VecToAngles, v1, v1) // convert origin to angle

Emp` 10-05-2006 00:14

Re: entity vector
 
Quote:

Originally Posted by VEN (Post 387721)
The whole task can be done quite simple, take a look

Code:
new Float:v1[3], Float:v2[3] pev(id, pev_origin, v1) // origin of the 1st player pev(id2, pev_origin, v2) // origin of the 2nd player xs_vec_sub(v2, v1, v1) // vector 1st->2nd engfunc(EngFunc_VecToAngles, v1, v1) // convert origin to angle

might not be aiming at a player all the time though

VEN 10-05-2006 04:01

Re: entity vector
 
EDIT:

And to make it aiming (for player) you have to set angle in the v_angle pev (not angles pev).

Basically if you have an origin:

Quote:

new Float:vec[3]
pev(ent, pev_origin, vec) // get the entity/player origin
xs_vec_sub(origin, vec, vec) // get the vector
engfunc(EngFunc_VecToAngles, vec, vec) // convert vector to angle
// set angles (entity) or v_angle (player) here

EDIT: there is the similar hl engine way: EngFunc_SetView (fakemeta), attach_view (engine) - sets player's view to entity


All times are GMT -4. The time now is 04:47.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.