Calculating fall distance
If a player jumps from a building and land in a random place, how can you calculate the fall distance?
Can you do this with pev_origin? If so, could anyone just give me a little code snippet? |
Re: Calculating fall distance
Code:
|
Re: Calculating fall distance
If the fall distance should be displayed in units, how can I make that? Lets say you jumped from a building and landed on the ground, then a HUD msg pops up and shows the fall distance.
Code:
set_hudmessage(255, 0, 0, -1.0, 0.8, 0, 6.0, 5.0, 0.1, 0.4, -1); |
Re: Calculating fall distance
All is done in client prethink :
When jump/fall : store player origin when land : check origin and calculate : stored Z origin - actual Z origin, result in units Just show your hudmessage where x-olent put "// you have the fall distance" distance is a float; so, in your message, replace %s with %.1f |
Re: Calculating fall distance
I did like you said and I getting errors on show_hudmessage, id is undentified.
Code:
set_hudmessage(255, 0, 0, -1.0, 0.8, 0, 6.0, 4.0, 0.1, 0.4, -1)EDIT: Nevermind, I got it right by setting client instead. Thanks for all the help. +karma. |
Re: Calculating fall distance
In about 20 minutes Ill be in my programming class so I will be able to rewrite it more efficiently instead of posting from my iPod.
|
Re: Calculating fall distance
That sounds great, Exo. Also, did you check my PM?
|
Re: Calculating fall distance
Code has been fixed.
|
Re: Calculating fall distance
Thanks a bunch, Exolent. Have fun at programming class. :)
|
Re: Calculating fall distance
@Exolent:
Code:
Also: Code:
I think that static vars are only to prevent creating vars multiple times like in Think forwards to decrease CPU or something. If you use new on every client_connect forward, it will recreate it every time the player connects. But if you use static, the variable already exists but resets. |
| All times are GMT -4. The time now is 01:53. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.