Raised This Month: $68 Target: $400
 17% 

Setting player velocity?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CoolJosh3k
AlliedModders Donor
Join Date: Mar 2010
Old 12-17-2013 , 17:21   Setting player velocity?
Reply With Quote #1

I am working on a rather complex plugin, but my experience is not what I would like it to be yet. So question:

What code can I use to set a players velocity?

I am able to provide the direction, speed and duration. I also have client id and timer setup, but I lack enough understanding of editing entity data.
CoolJosh3k is offline
NIGathan
Senior Member
Join Date: Aug 2011
Location: /dev/null
Old 12-17-2013 , 20:58   Re: Setting player velocity?
Reply With Quote #2

PHP Code:
// To get the player velocity:
new Float:vec[3];
GetEntPropVector(clientProp_Data"m_vecVelocity"vec);

// Here we can modify the data in the array
vec[3] = 300.0// Raise the player 300 units upward.

// Then to set the players velocity we will do:
TeleportEntity(clientNULL_VECTORNULL_VECTORvec); 
NIGathan is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 12-17-2013 , 22:52   Re: Setting player velocity?
Reply With Quote #3

Quote:
Originally Posted by NIGathan View Post
PHP Code:

// Here we can modify the data in the array
vec[3] = 300.0// Raise the player 300 units upward. 
vec[2] = 300.0;
__________________
Now taking private request.
Steam Profile | Donation are welcome.
GsiX is offline
CoolJosh3k
AlliedModders Donor
Join Date: Mar 2010
Old 12-18-2013 , 23:52   Re: Setting player velocity?
Reply With Quote #4

Thankyou, I will try this. Didn't realize you could set it using a teleport input. Clever.
CoolJosh3k is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 12-19-2013 , 00:57   Re: Setting player velocity?
Reply With Quote #5

That works too, confirmed;
Code:
/**
 * Sets the Base velocity of an entity.
 * The base velocity is the velocity applied
 * to the entity from other sources .
 *
 * @param entity        Entity index.
 * @param vel            An 3 dim array
 * @noreturn
 */
stock Entity_SetBaseVelocity(entity, const Float:vec[3])
{
    SetEntPropVector(entity, Prop_Data, "m_vecBaseVelocity", vec);
}
/ smlib
__________________
retired
shavit is offline
CoolJosh3k
AlliedModders Donor
Join Date: Mar 2010
Old 12-19-2013 , 03:35   Re: Setting player velocity?
Reply With Quote #6

Quote:
Originally Posted by shavit View Post
That works too, confirmed;
Code:
/**
 * Sets the Base velocity of an entity.
 * The base velocity is the velocity applied
 * to the entity from other sources .
 *
 * @param entity        Entity index.
 * @param vel            An 3 dim array
 * @noreturn
 */
stock Entity_SetBaseVelocity(entity, const Float:vec[3])
{
    SetEntPropVector(entity, Prop_Data, "m_vecBaseVelocity", vec);
}
/ smlib
This looks like a much better way to do it. The kind of thing I was thinking of, but thought the engine would not allow it.

Thanks for this :)
CoolJosh3k is offline
NIGathan
Senior Member
Join Date: Aug 2011
Location: /dev/null
Old 12-20-2013 , 04:10   Re: Setting player velocity?
Reply With Quote #7

Quote:
Originally Posted by GsiX View Post
vec[2] = 300.0;
Oh wow... Whoops.
NIGathan is offline
CoolJosh3k
AlliedModders Donor
Join Date: Mar 2010
Old 01-07-2014 , 19:34   Re: Setting player velocity?
Reply With Quote #8

Been writing some code and testing things, in which I found some interesting results.

in m_vecBaseVelocity based on the 3 possible vectors...

'x' will move you towards the positive y direction if your y eye angle is in the Quadrants 1 or 2 (0 to +180), but negative direction if your angle is in the Q3/Q4 (-180 to 0)

'y' will move you towards the x direction when your eye angle is Q1/Q4 (-90 to +90) and reversed for the other 2 quads

'z' will actually move you toward whatever direction you are already moving.


EDIT: Later testing with this, seem to send the player in the expected way. -100 sends the player towards the negative x direction. Unsure why my results changed.

All of these only work when the client in moving in both the horizontal and vertical planes. It also appears to ramp up the speed, rather than directly setting it.

Last edited by CoolJosh3k; 01-12-2014 at 01:59.
CoolJosh3k is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 01-08-2014 , 02:32   Re: Setting player velocity?
Reply With Quote #9

I m not sure about all this stuff but I think it depend on how the map being constructed will defined your origin and angle.
__________________
Now taking private request.
Steam Profile | Donation are welcome.
GsiX is offline
NIGathan
Senior Member
Join Date: Aug 2011
Location: /dev/null
Old 01-08-2014 , 15:27   Re: Setting player velocity?
Reply With Quote #10

By x,y, and z do you mean 0,1, and 2 relatively?

Also I believe setting the m_vecBaseVelocity will alter the m_vecVelocity based off what you give it. It won't actually change it to what you set. So for example:

m_vecVelocity is currently 42,42,0.
If you change the m_vecBaseVelocity to -42,-42,0 then the player will actually have no velocity at all.

If you are trying to actually set the velocity then set m_vecVelocity.

Last edited by NIGathan; 01-08-2014 at 15:33.
NIGathan is offline
Reply


Thread Tools
Display Modes

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 17:42.


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