Player Speed
How would one calculate the speed of a player as a single number based on the player's three velocities in X, Y, and Z?
(I'm actually only interested in the speed based on the X and the Y) |
Re: Player Speed
PHP Code:
|
Re: Player Speed
...that's what I already know. I want to know what the speed is, based on that -- not how to set it.
For instance, if the max player speed is 500, and the player is walking down the X axis, then X = 500 and Y = 0. However, I want to work from the other direction. If I'm given that X = 114 and Y = 372, then what is the combined "speed"? |
Re: Player Speed
watch code above
|
Re: Player Speed
No. I don't want to set anything, I just want to know what the combined speed of the two vectors is, but I have nooo idea how to do vector addition in this way.
PHP Code:
What if someone had done the following: PHP Code:
Our problem is set one second after the velocity_by_aim has been applied to my character. How would I, based on my pev_velocity, calculate that I am moving at this speed of 500? |
Re: Player Speed
new g_Velocity[3];
pev(index, pev_velocity, g_Velocity); g_Velocity[2] = 0 // speed is a float : client_print(id,print_center,"%f", vector_lengh(g_Velocity)) |
Re: Player Speed
Holy s***! vector_length was exactly what I was looking for. Thank you so much!
Just curious, but does anyone have any idea how that length is calculated within that function? |
Re: Player Speed
From xs.inc (result will be the same but vector_lengh might be faster) :
Float: xs_vec_len(const Float:vec[]) { return xs_sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]); } |
Re: Player Speed
That's really weird... I had tried to calculate that and I didn't get the same answer. I was so confused as to where I had gone wrong.
I guess I typed something in wrong. Either way, thank you very much. |
| All times are GMT -4. The time now is 09:07. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.