AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Gravity to Velocity (https://forums.alliedmods.net/showthread.php?t=196220)

malec321 09-16-2012 20:23

Gravity to Velocity
 
Okay so I have a part of the trampoline code,
Code:

                entity_get_vector(id, EV_VEC_velocity, velocity);
                velocity[2] = 500;                               
                entity_set_vector(id, EV_VEC_velocity, velocity);
               
                entity_set_int(id, EV_INT_gaitsequence, 6);

and I want to make it so if you touch that above trampoline while having lower gravity, it continues your gravity while throwing you up in the air. How would I go by doing this?

Thanks all! :)

(And yes this is the trampoline code from blockmaker, no I'm not going to release this in any way)

mabaclu 09-17-2012 10:55

Re: Gravity to Velocity
 
velocity[2] = 500 * user gravity

malec321 09-17-2012 18:06

Re: Gravity to Velocity
 
Code:

GetUserGravity(id)
{
    static sv_gravity
    if( !sv_gravity )
    {
        sv_gravity = get_cvar_pointer("sv_gravity")
    }
    return floatround( get_user_gravity(id) * get_pcvar_float(sv_gravity) )
}

I saw connor post this on a different thread, tried to use it with the way you said

Code:

velocity[2] = 500 * get_user_gravity(id);
didn't work probably some stupid thing I'm missing or getting gravity that way isn't the way I should do it?

mabaclu 09-17-2012 19:11

Re: Gravity to Velocity
 
Remove the 500. In theory the more gravity you have the higher the speed you jump with to achieve a static height.
If gravity is 800 you jump with the speed of 800 * x. If your gravity is 100 then youll jump with a vertical velocity of 100 * x.
x here is a small number you can change (but 500 is too big). In theory this should work.
Try removing the multiplication by 500 for now.

malec321 09-17-2012 23:33

Re: Gravity to Velocity
 
If I was to remove the 500, the trampoline wouldn't throw me at the 500 speed or whatever you want to call it, as the point of this isn't the gravity, it's a trampoline which throws you at 500 with normal 800 gravity, but if you were to hit it while you had gravity on, you would get thrown 500 speed upward and still have the gravity is what I wan't to do

Pretty much, x block is gravity .. if you touch this and jump off of it your gravity is set to 200 until you touch the floor, what I want to do is make it so if you touch the trampoline instead of the floor, it would throw you up x amount but still maintain that 200 gravity until you touch the floor

mabaclu 09-18-2012 03:07

Re: Gravity to Velocity
 
I dont understand... the gravity doesnt change during the jump. Do you want the trampoline to send you at a fixed height no matter what your gravity is?

malec321 09-18-2012 21:36

Re: Gravity to Velocity
 
Quote:

Originally Posted by mabaclu (Post 1801679)
Do you want the trampoline to send you at a fixed height no matter what your gravity is?

That's what it does right now and I don't want it to do that. I want it to continue the gravity after being thrown

jimaway 09-19-2012 02:55

Re: Gravity to Velocity
 
look into the gravity block code, and edit it so it wont reset the gravity when touching trampoline


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

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