AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   velocity (https://forums.alliedmods.net/showthread.php?t=21815)

SubFive 12-11-2005 04:14

velocity
 
Could someone tell me the specifics of get_user_velocity? I've searched the doc and the forums and both have very little information about it.

I understand:
Code:
if (Velocity[0] == 0 && Velocity[1] == 0 && Velocity[2] == 0)
What do each one of those represent though?

Is [0] x, [1] y, and [2] z?

VEN 12-11-2005 06:58

Yes. Velocity may be negative value. Since origin may be negative either.

EDIT:
I think this values have dimension unit like [distance_units per second]

SubFive 12-11-2005 14:53

So correct me if I'm wrong, but wouldn't someones (z) velocity be at about 0 if they were at the peak of a jump? Wouldn't their velocity (z) be at exactly 0 if they weren't jumping at all? How can I distinguish between the two?

XxAvalanchexX 12-11-2005 19:19

Search for a negative velocity which means they are going upwards. Once you know they are going upwards check to see when their velocity nears 0. Tada. Also use EV_FL_flFallVelocity.

SubFive 12-11-2005 19:23

Thanks again, both of you! I'll be honest though and say I don't exactly know how to use EV_FL_flFallVelocity.

SubFive 12-12-2005 00:52

Could you please confirm the following?

If they aren't jumping or moving vertically, their z velocity is 0. If they are at the exact peak of a jump and aren't moving up or down anymore for a split second, their z velocity is also at 0, isn't it?

So what goes in between?
When you jump, is your z velocity immediately about -20 (or whatever the actual number for the peak of a jump is, or is it graduate?

For example:
Graduate:
http://server2.ihostphotos.com/show.php?id=36693

Immediate:
http://server2.ihostphotos.com/show.php?id=36695

I'm pretty confused, my brain hurts, and I'm not great at physics. Could someone please enlighten me on this? To make it simple, I just want an if statement that catches what the user's z velocity is, and if hes near the top of a jump, to do something.

XxAvalanchexX 12-12-2005 01:11

Yes, you are falling at a speed of 0.0 while on the ground and reach 0.0 while at the peak of your jump (not exactly, but very close). So, you have to make sure the user jumped first, check for when they slow down, and make sure that once you acknowledge they slowed down you don't check anymore (ie: so it doesn't get called again when they hit the ground).

Tested, works fine:

Code:
#include <amxmodx>  #include <engine>  new bool:didJump[33];  new bool:didPeak[33];  public client_PreThink(id) {     if( !is_user_alive(id) )         return;     if( (get_user_button(id) & IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !didJump[id] )         didJump[id] = true;     else if( (get_entity_flags(id) & FL_ONGROUND) && didJump[id] ) {         didJump[id] = false;         didPeak[id] = false;     }  }  public client_PostThink(id) {     if( !didJump[id] || didPeak[id] )         return;     new Float:fall = entity_get_float(id,EV_FL_flFallVelocity);     if( fall >= -5.0 && fall < 5.0 ) {         didPeak[id] = true;         peak(id);     }  }  public peak(id) {     client_print(id,print_chat,"* PEAK!");  }

SubFive 12-12-2005 18:54

Thanks for your post Avalance, you're very helpful. :D

Thats a lot to digest, especially without comments, so I'll get back to you because I'll probably run into trobule figuring out how to intergrade that into my script. Thanks again. +kudos, +karma, +etc.


All times are GMT -4. The time now is 16:11.

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