Raised This Month: $ Target: $400
 0% 

entity vector


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheNewt
Donor
Join Date: Jun 2006
Location: Where I live.
Old 10-04-2006 , 15:38   entity vector
Reply With Quote #1

[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.
__________________
Quote:
toe3_ left the chat room. (G-lined (AUTO Excessive connections from a single host.))

Last edited by TheNewt; 10-04-2006 at 18:43.
TheNewt is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 10-04-2006 , 15:57   Re: entity vector
Reply With Quote #2

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?
__________________
EAT YOUR VEGGIES
Silencer123 is offline
TheNewt
Donor
Join Date: Jun 2006
Location: Where I live.
Old 10-04-2006 , 16:00   Re: entity vector
Reply With Quote #3

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.
__________________
Quote:
toe3_ left the chat room. (G-lined (AUTO Excessive connections from a single host.))

Last edited by TheNewt; 10-04-2006 at 16:07.
TheNewt is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 10-04-2006 , 16:13   Re: entity vector
Reply With Quote #4

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').
__________________
EAT YOUR VEGGIES
Silencer123 is offline
TheNewt
Donor
Join Date: Jun 2006
Location: Where I live.
Old 10-04-2006 , 16:30   Re: entity vector
Reply With Quote #5

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.
__________________
Quote:
toe3_ left the chat room. (G-lined (AUTO Excessive connections from a single host.))
TheNewt is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 10-04-2006 , 17:02   Re: entity vector
Reply With Quote #6

Quote:
Originally Posted by MysticDeath View Post
But it faces the opposite direction, all the time.
How about not subtracting 180 from newAngle[1]?
stupok is offline
TheNewt
Donor
Join Date: Jun 2006
Location: Where I live.
Old 10-04-2006 , 17:25   Re: entity vector
Reply With Quote #7

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,
__________________
Quote:
toe3_ left the chat room. (G-lined (AUTO Excessive connections from a single host.))
TheNewt is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 10-05-2006 , 00:10   Re: entity vector
Reply With Quote #8

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
VEN is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 10-05-2006 , 00:14   Re: entity vector
Reply With Quote #9

Quote:
Originally Posted by VEN View Post
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
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Old 10-05-2006, 00:59
VEN
This message has been deleted by VEN. Reason: non-minor edit - reposting
VEN
Veteran Member
Join Date: Jan 2005
Old 10-05-2006 , 04:01   Re: entity vector
Reply With Quote #10

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

Last edited by VEN; 10-05-2006 at 08:49.
VEN is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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