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

calc with vectors/angles ... how to make a client look to my abs-position


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tauphi
SourceMod Donor
Join Date: Sep 2004
Location: Germany
Old 09-22-2008 , 22:54   calc with vectors/angles ... how to make a client look to my abs-position
Reply With Quote #1

Hello,

I want to change the viewing angles of a given client, that he looks to my own absolute position ...

PHP Code:
public SetClientLookAtMeme client ) {
    new 
Float:myPosition[3];
    new 
Float:hisPosition[3];
    new 
Float:newAngle[3];
    
    
GetClientAbsOrigin(me,myPosition);
    
GetClientAbsOrigin(client,hisPosition);
    
    
/*
        how can i calculate the angles from the two positions,
        that the client looks/aims to me ?
    */
    
    
TeleportEntity(clientNULL_VECTORnewAngleNULL_VECTOR);

any ideas how to code this? :-/

thx in advance
andi
__________________
Tauphi is offline
Send a message via ICQ to Tauphi Send a message via Skype™ to Tauphi
Sammy-ROCK!
Senior Member
Join Date: Jun 2008
Location: Near Mrs.Lag
Old 09-22-2008 , 23:40   Re: calc with vectors/angles ... how to make a client look to my abs-position
Reply With Quote #2

GetClientAbsOrigin : Below the client. Where he's standing.
also wouldn't
SetClientViewEntity work? I never used this stock so I don't really know.
Sammy-ROCK! is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 09-23-2008 , 13:06   Re: calc with vectors/angles ... how to make a client look to my abs-position
Reply With Quote #3

I haven't worked with vectors in a while, but I believe you could just do:
PHP Code:
new Float:temp[3];
MakeVectorFromPoints(myPositionhisPositiontemp);
GetVectorAngles(tempnewAngle); 
And then just use TeleportEntity like you did in your post. If it doesn't work right, try switching the two position vectors in the MakeVectorFromPoints function.

Last edited by bl4nk; 09-23-2008 at 13:08.
bl4nk is offline
Tauphi
SourceMod Donor
Join Date: Sep 2004
Location: Germany
Old 09-23-2008 , 14:12   Re: calc with vectors/angles ... how to make a client look to my abs-position
Reply With Quote #4

bl4nk you are my hero ... thanks a lot ...

here is the working code:
PHP Code:
public SetClientLookAtMeme client ) { 
    new 
Float:myPosition[3]; 
    new 
Float:hisPosition[3]; 
    new 
Float:newAngle[3]; 
     
    
GetClientAbsOrigin(me,myPosition); 
    
GetClientAbsOrigin(client,hisPosition); 
    
    new 
Float:temp[3];
    
MakeVectorFromPoints(hisPosition,myPosition,temp);
    
GetVectorAngles(temp,newAngle);
    
    
//looking to the top --> 0 > newAngle[0] > -90.0
    
if ( newAngle[0] > 90.0 ) {
        
newAngle[0] = (360.0-newAngle[0])*-1.0;
        if ( 
newAngle[0] < -90.0 newAngle[0] = -89.9;
    }
     
    
TeleportEntity(clientNULL_VECTORnewAngleNULL_VECTOR); 

__________________
Tauphi is offline
Send a message via ICQ to Tauphi Send a message via Skype™ to Tauphi
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 07:26.


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