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

NegateVector() broken?


Post New Thread Reply   
 
Thread Tools Display Modes
fiction
Member
Join Date: May 2017
Old 09-14-2017 , 03:11   Re: NegateVector() broken?
Reply With Quote #21

Quote:
Originally Posted by tonline_kms65 View Post
The basic meaning of the question of the author was - a turn of the camera angles of the player.
He tried to do it with NegatiVector.
I also failed with NegativeVector to deploy the camera angles of the player, how can I do this?
Do you just want to turn the player around backwards? If so try something like this:
PHP Code:
    [...]

    
float fAngles[3];
    
GetClientEyeAngles(clientfAngles);

    
fAngles[1] += 180.0;
    
NormalizeAngle(fAngles[1]);

    
TeleportEntity(clientNULL_VECTORfAnglesNULL_VECTOR);

    [...]

void NormalizeAngle(float &angle)
{
    while(
angle < -180.0)
        
angle += 360.0;

    while(
angle 180.0)
        
angle -= 360.0;


Last edited by fiction; 09-14-2017 at 03:42.
fiction is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 09-14-2017 , 03:28   Re: NegateVector() broken?
Reply With Quote #22

Why on earth are you using FloatAdd instead of +?
__________________
asherkin is offline
fiction
Member
Join Date: May 2017
Old 09-14-2017 , 03:44   Re: NegateVector() broken?
Reply With Quote #23

Quote:
Originally Posted by asherkin View Post
Why on earth are you using FloatAdd instead of +?
Because c+p, I've updated my post. Thanks
fiction is offline
tonline_kms65
Member
Join Date: Aug 2016
Location: Ru. Komsomol-on-Amur
Old 09-15-2017 , 05:19   Re: NegateVector() broken?
Reply With Quote #24

Quote:
Originally Posted by fiction View Post
Do you just want to turn the player around backwards? If so try something like this:
PHP Code:
    [...]

    
float fAngles[3];
    
GetClientEyeAngles(clientfAngles);

    
fAngles[1] += 180.0;
    
NormalizeAngle(fAngles[1]);

    
TeleportEntity(clientNULL_VECTORfAnglesNULL_VECTOR);

    [...]

void NormalizeAngle(float &angle)
{
    while(
angle < -180.0)
        
angle += 360.0;

    while(
angle 180.0)
        
angle -= 360.0;

Thank you so much! My problem was to make a turn the entity(Drone) face to the calling player.
Only 3 lines of code solved this problem.
PHP Code:
client_angle[1] += 180.0;                                                     
if(
client_angle[1] < -180.0client_angle[1] += 360.0;
if(
client_angle[1] > 180.0)  client_angle[1] -= 360.0
Video where is used this code

Last edited by tonline_kms65; 09-15-2017 at 05:41.
tonline_kms65 is offline
tonline_kms65
Member
Join Date: Aug 2016
Location: Ru. Komsomol-on-Amur
Old 09-15-2017 , 05:42   Re: NegateVector() broken?
Reply With Quote #25

Quote:
Originally Posted by asherkin View Post
Why on earth are you using FloatAdd instead of +?
Probably for smooth turning.
tonline_kms65 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-15-2017 , 11:38   Re: NegateVector() broken?
Reply With Quote #26

Quote:
Originally Posted by tonline_kms65 View Post
Probably for smooth turning.
There's no difference between the two (the operator and FloatAdd).
klippy is offline
tonline_kms65
Member
Join Date: Aug 2016
Location: Ru. Komsomol-on-Amur
Old 09-15-2017 , 17:00   Re: NegateVector() broken?
Reply With Quote #27

PHP Code:
drone_angle[1] = FloatAdd(drone_angle[1], 2.0); 

or
PHP Code:
drone_angle[1] = drone_angle[1] + 2.0


In principle Yes, I agree.

Last edited by tonline_kms65; 09-15-2017 at 17:03.
tonline_kms65 is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 09-15-2017 , 17:13   Re: NegateVector() broken?
Reply With Quote #28

FloatAdd is the native that implements the + operator, that is literally its purpose, it should never be used directly (and it is likely any code using the internal Float* natives will break in the future, they are internal API).
__________________
asherkin 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 03:17.


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