Raised This Month: $32 Target: $400
 8% 

Position in front and right


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 12-08-2017 , 12:39   Position in front and right
Reply With Quote #1

How can i implement that code to get a position in right and forward from the player? Now i can get position just from the front

PHP Code:
#define FORWARD_DISTANCE 100.0

// Initialize vectors
static float vEntPosition[3]; static float vEntAngle[3]; 

// Gets the origin
....GetAbsOrigin(nEntityvEntPosition);

// Gets the  eye angle
....GetEyeAngle(nEntityvEntAngle);

// Calculate effect area origin
vEntPosition[0] = vEntPosition[0] + (FORWARD_DISTANCE Cosine(DegToRad(vEntAngle[1])));
vEntPosition[1] = vEntPosition[1] + (FORWARD_DISTANCE Sine(DegToRad(vEntAngle[1]))); 
__________________

Last edited by gubka; 12-08-2017 at 22:43.
gubka is offline
Send a message via ICQ to gubka
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 12-11-2017 , 11:52   Re: Position in front and right
Reply With Quote #2

You don't need to touch any sine or cosine for that. That's possible through the provided vector api. Have a look at GetAngleVectors, ScaleVector and AddVectors.
__________________
Peace-Maker is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 12-11-2017 , 12:36   Re: Position in front and right
Reply With Quote #3

Is This what you're looking for?

PHP Code:
float fForward[3], fRight[3], fUp[3];
GetAngleVectors(vEntAnglefForwardfRightfUp);

vEntPosition[0] = vEntPosition[0] + fForward[0] * FORWARD_DISTANCE fRight[0] * RIGHT_DISTANCE;
vEntPosition[1] = vEntPosition[1] + fForward[1] * FORWARD_DISTANCE fRight[1] * RIGHT_DISTANCE
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards 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 13:30.


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