AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [solved]gravity math! (https://forums.alliedmods.net/showthread.php?t=152906)

frk_14 03-16-2011 00:03

[solved]gravity math!
 
someone know how is the calculation (i dont know if is the correct word) that uses the engine to imitate the gravity in game?
i need to predict how many speed need set to a entity to proximity to "X" height

wrecked_ 03-16-2011 01:19

Re: gravity math!
 
Check these links out.

http://forums.alliedmods.net/showthr...t=gravity+math
http://en.wikipedia.org/wiki/Trajectory_of_a_projectile

Exolent[jNr] 03-16-2011 03:05

Re: gravity math!
 
Code:
Float:GetHeightVelocity(ent, Float:height) {     static sv_gravity;     if(sv_gravity || (sv_gravity = get_cvar_pointer("sv_gravity")))     {         return floatsqroot(2.0 * get_pcvar_float(sv_gravity) * entity_get_float(ent, EV_FL_gravity) * height);     }     return 0.0; }

Usage:
Code:
new Float:velocity[3]; entity_get_vector(id, EV_VEC_velocity, velocity); velocity[2] = GetHeightVelocity(id, 500.0); // send player up 500 units entity_set_vector(id, EV_VEC_velocity, velocity);

Use this site as a reference for some more gravity calculations:
http://home.roadrunner.com/~sccinfo/scigrav.htm

frk_14 03-16-2011 21:32

Re: gravity math!
 
thanks, is really useful.


All times are GMT -4. The time now is 14:31.

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