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

Solved get origin on front of player but slightly left?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
heroicpower7613
Member
Join Date: Nov 2016
Old 11-17-2019 , 15:21   get origin on front of player but slightly left?
Reply With Quote #1

hey.
how do I calculate the position on front of a client but slightly to left?

like so:


here's a code to get origin directly in front of player:

Quote:
Originally Posted by zipcore View Post
better use this:

PHP Code:
stock void AddInFrontOf(float vecOrigin[3], float vecAngle[3], float unitsfloat output[3])
{
    
float vecAngVectors[3];
    
vecAngVectors vecAngle//Don't change input
    
GetAngleVectors(vecAngVectorsvecAngVectorsNULL_VECTORNULL_VECTOR);
    for (
int i3i++)
    
output[i] = vecOrigin[i] + (vecAngVectors[i] * units);

but that's not exactly what I'm after.
thanks.

Last edited by heroicpower7613; 11-17-2019 at 23:08. Reason: solved!
heroicpower7613 is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 11-17-2019 , 15:35   Re: get origin on front of player but slightly left?
Reply With Quote #2

This is 45 degrees to the left, and I'll give it 80 units from the player's position. IDK if I need to reduce or add 45 degrees but try this:

new Float:EyeOrigin[3], Float:EyeAngles[3], Float:TestAngle[3];

GetClientEyePosition(client, EyeOrigin);
GetClientEyeAngles(client, EyeAngles);

EyeAngles[1] += 45.0;

GetAngleVectors(EyeAngles, TestAngle, NULL_VECTOR, NULL_VECTOR);

for(new i=0;i < 3;i++)
{
Origin[i] += TestAngle[i] * 80.0;
}

Note: I'm bad at vectors so this might be horribly wrong.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Stugger
Member
Join Date: Sep 2007
Old 11-17-2019 , 15:55   Re: get origin on front of player but slightly left?
Reply With Quote #3

You can give this a shot

Code:
float direction[3], newPosition[3];

// Here we get the forward vector of the client, set the distance to move forward and store it
GetAngleVectors(clientAngles, direction, NULL_VECTOR, NULL_VECTOR);
ScaleVector(direction, FLOAT_UNITS_TO_MOVE_FORWARD);
AddVectors(clientPosition, direction, newPosition);
						
// Then from the forwards position, get the right vector, negate it since we want to move left, set the distance to move left and overwrite newPosition
GetAngleVectors(clientAngles, NULL_VECTOR, direction, NULL_VECTOR);
NegateVector(direction);
ScaleVector(direction, FLOAT_UNITS_TO_MOVE_LEFT);
AddVectors(newPosition, direction, newPosition);

Last edited by Stugger; 11-17-2019 at 15:57.
Stugger is offline
heroicpower7613
Member
Join Date: Nov 2016
Old 11-17-2019 , 23:01   Re: get origin on front of player but slightly left?
Reply With Quote #4

Quote:
Originally Posted by eyal282 View Post
This is 45 degrees to the left, and I'll give it 80 units from the player's position. IDK if I need to reduce or add 45 degrees but try this:
hey thanks for the reply, but I don't think it worked.


Quote:
Originally Posted by Stugger View Post
You can give this a shot
thanks so much, it works very well!

here is the stock if anyone needs it.
PHP Code:
stock void AddInFrontOffloat fOrigin[3], float fAngles[3], float fDistanceToFrontfloat fDistanceToLeftfloat fOutput[3] )
{
    
float fDir[3];

    
GetAngleVectors(fAnglesfDirNULL_VECTORNULL_VECTOR);
    
ScaleVector(fDirfDistanceToFront);
    
AddVectors(fOriginfDirfOutput);
                            
    
GetAngleVectors(fAnglesNULL_VECTORfDirNULL_VECTOR);
    
NegateVector(fDir);
    
ScaleVector(fDirfDistanceToLeft);
    
AddVectors(fOutputfDirfOutput);

heroicpower7613 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 06:45.


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