Raised This Month: $51 Target: $400
 12% 

vector_to_angle, formula?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 08-18-2008 , 11:13   vector_to_angle, formula?
Reply With Quote #1

I need to change a vector into an angle vector but don't know a formula to do this, and I'm pretty sure there isn't a function for SourceMod that does this yet (that I could find).

Here is the function for AMXX that worked:
vector_to_angle
hlstriker is offline
DiscoBBQ
Veteran Member
Join Date: Jan 2005
Location: Clemson, South Carolina
Old 08-18-2008 , 11:35   Re: vector_to_angle, formula?
Reply With Quote #2

You are going to need to use rectangular to polar coordinate conversions.
Read: http://www.teacherschoice.com.au/Mat...conversion.htm

If you could be a little more specific in what you are doing I would be able to help you more.
__________________
"Every man is guilty of all the good he did not do"
DiscoBBQ is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 08-18-2008 , 11:46   Re: vector_to_angle, formula?
Reply With Quote #3

I'm trying to make one entity face another entity.

Here is the code that will work if I can use that function:
PHP Code:
static Float:flClientOrigin[3], Float:flEntOrigin[3];
GetEntDataVector(iClientg_offEntityOriginflClientOrigin);
GetEntDataVector(iEntg_offEntityOriginflEntOrigin);

static 
Float:flNewVec[3];
flNewVec[0] = flClientOrigin[0] - flEntOrigin[0];
flNewVec[1] = flClientOrigin[1] - flEntOrigin[1];
flNewVec[2] = flClientOrigin[2] - flEntOrigin[2];

static 
Float:flEntAngles[3];
// Here is where I need the function...
vector_to_angle(flNewVecflEntAngles);

TeleportEntity(iEntNULL_VECTORflEntAnglesNULL_VECTOR); 

Last edited by hlstriker; 09-25-2008 at 11:24.
hlstriker is offline
DiscoBBQ
Veteran Member
Join Date: Jan 2005
Location: Clemson, South Carolina
Old 08-18-2008 , 12:26   Re: vector_to_angle, formula?
Reply With Quote #4

This will turn the iEnt and make it face the iClient.

Code:
 
//Declare:
decl Float:flClientOrigin[3], Float:flEntOrigin[3], Float:flEntAngles[3];
 
//Initialize:
GetEntDataVector(iClient, g_offEntityOrigin, flClientOrigin);
GetEntDataVector(iEnt, g_offEntityOrigin, flEntOrigin);
GetClientAbsAngles(iClient, flEntAngles);
 
//Z Axis:
flEntAngles[1] = ArcTangent(flClientOrigin[1]/flClientOrigin[0]);
 
//Send:
TeleportEntity(iEnt, NULL_VECTOR, flEntAngles, NULL_VECTOR);
It should work fine assuming player angles in the mod your trying on uses the default QAngles, as shown here:
http://developer.valvesoftware.com/wiki/Angle
__________________
"Every man is guilty of all the good he did not do"
DiscoBBQ is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 08-18-2008 , 12:27   Re: vector_to_angle, formula?
Reply With Quote #5

I just found GetVectorAngles()...

Pretty sure this is what I needed.

EDIT:
Just saw your latest post. Thanks for showing how to do it
hlstriker is offline
DiscoBBQ
Veteran Member
Join Date: Jan 2005
Location: Clemson, South Carolina
Old 08-18-2008 , 12:31   Re: vector_to_angle, formula?
Reply With Quote #6

No problem bro
__________________
"Every man is guilty of all the good he did not do"
DiscoBBQ 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:20.


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