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

OnPlayerRunCmd calculate velocity to walk towards a point


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 09-19-2015 , 14:24   OnPlayerRunCmd calculate velocity to walk towards a point
Reply With Quote #1

I want to have a player automatically walk towards a position regardless of their rotation (No force look towards direction)

We know that:
0.0 -450.0 0.0 left
0.0 450.0 0.0 right
450.0 0.0 0.0 forward
-450.0 0.0 0.0 back

and i don't want to use TeleporEntity
__________________
Pelipoika is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 09-19-2015 , 14:51   Re: OnPlayerRunCmd calculate velocity to walk towards a point
Reply With Quote #2

normalize(to - from) * 450
Miu is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 09-19-2015 , 15:03   Re: OnPlayerRunCmd calculate velocity to walk towards a point
Reply With Quote #3

Quote:
Originally Posted by Miu View Post
normalize(to - from) * 450
PHP Code:
float flMoveVel[3];
MakeVectorFromPoints(flPosflNodePosflMoveVel);
NormalizeVector(flMoveVelflMoveVel) * 450
Doesn't seem right
__________________
Pelipoika is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 09-19-2015 , 20:11   Re: OnPlayerRunCmd calculate velocity to walk towards a point
Reply With Quote #4

as in multiply the resultant vector by 450
Miu is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 09-20-2015 , 02:31   Re: OnPlayerRunCmd calculate velocity to walk towards a point
Reply With Quote #5

scalevector
__________________
Chdata is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 09-20-2015 , 05:38   Re: OnPlayerRunCmd calculate velocity to walk towards a point
Reply With Quote #6

Quote:
Originally Posted by Miu View Post
as in multiply the resultant vector by 450
PHP Code:
float flMoveVel[3];
MakeVectorFromPoints(flPosflNodePosflMoveVel);
NormalizeVector(flMoveVelflMoveVel);
ScaleVector(flMoveVel450.0); 
Doesnt' work like i want, i need a velocity like -450.0 450.0 0.0 that i can copy to the vel param of OnPlayerRunCmd so i can't just make a vector from 2 points and copy that
__________________

Last edited by Pelipoika; 09-20-2015 at 05:51.
Pelipoika is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 09-20-2015 , 07:45   Re: OnPlayerRunCmd calculate velocity to walk towards a point
Reply With Quote #7

If you just like to fake the movement keys you can only have 8 directions the player can move too.

Use teleport entity...which doesn't mean it teleports the player but overwriting the player velocity...
__________________
zipcore is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 09-20-2015 , 08:18   Re: OnPlayerRunCmd calculate velocity to walk towards a point
Reply With Quote #8

Quote:
Originally Posted by zipcore View Post
Use teleport entity...which doesn't mean it teleports the player but overwriting the player velocity...
But i don't want to overwrite their velocity
__________________
Pelipoika is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 09-20-2015 , 15:58   Re: OnPlayerRunCmd calculate velocity to walk towards a point
Reply With Quote #9

seems like this works

PHP Code:
public Action OnPlayerRunCmd(int clientint &buttonsint &impulsefloat move[3], float angles[3], int &weaponint &subtypeint &cmdnumint &tickcountint &seedint mouse[2])
{
    
float pos[3];
    
GetClientAbsOrigin(clientpos);
    
    static 
float dest[3]; // place u want to go
    
    
float newmove[3];
    
    
pos[2] = 0.0;
    
dest[2] = 0.0;
    
    
SubtractVectors(destposnewmove);
    
NormalizeVector(newmovenewmove);
    
ScaleVector(newmove450.0);
    
    
newmove[1] = -newmove[1];
    
    
float sin Sine(angles[1] * FLOAT_PI 180.0);
    
float cos Cosine(angles[1] * FLOAT_PI 180.0);
    
move[0] = cos newmove[0] - sin newmove[1];
    
move[1] = sin newmove[0] + cos newmove[1];
    
    return 
Plugin_Changed;

Miu is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 09-20-2015 , 16:27   Re: OnPlayerRunCmd calculate velocity to walk towards a point
Reply With Quote #10

Quote:
Originally Posted by Miu View Post
seems like this works

PHP Code:
public Action OnPlayerRunCmd(int clientint &buttonsint &impulsefloat move[3], float angles[3], int &weaponint &subtypeint &cmdnumint &tickcountint &seedint mouse[2])
{
    
float pos[3];
    
GetClientAbsOrigin(clientpos);
    
    static 
float dest[3]; // place u want to go
    
    
float newmove[3];
    
    
pos[2] = 0.0;
    
dest[2] = 0.0;
    
    
SubtractVectors(destposnewmove);
    
NormalizeVector(newmovenewmove);
    
ScaleVector(newmove450.0);
    
    
newmove[1] = -newmove[1];
    
    
float sin Sine(angles[1] * FLOAT_PI 180.0);
    
float cos Cosine(angles[1] * FLOAT_PI 180.0);
    
move[0] = cos newmove[0] - sin newmove[1];
    
move[1] = sin newmove[0] + cos newmove[1];
    
    return 
Plugin_Changed;

It does indeed, Thank you you great math-magician
__________________
Pelipoika 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 01:30.


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