Raised This Month: $ Target: $400
 0% 

Gravity to Velocity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 09-16-2012 , 20:23   Gravity to Velocity
Reply With Quote #1

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)
__________________
Ayyylmao
malec321 is offline
mabaclu
Senior Member
Join Date: Jun 2010
Location: Portugal
Old 09-17-2012 , 10:55   Re: Gravity to Velocity
Reply With Quote #2

velocity[2] = 500 * user gravity
__________________
mabaclu is offline
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 09-17-2012 , 18:06   Re: Gravity to Velocity
Reply With Quote #3

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?
__________________
Ayyylmao
malec321 is offline
mabaclu
Senior Member
Join Date: Jun 2010
Location: Portugal
Old 09-17-2012 , 19:11   Re: Gravity to Velocity
Reply With Quote #4

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.
__________________

Last edited by mabaclu; 09-17-2012 at 19:12.
mabaclu is offline
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 09-17-2012 , 23:33   Re: Gravity to Velocity
Reply With Quote #5

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
__________________
Ayyylmao
malec321 is offline
mabaclu
Senior Member
Join Date: Jun 2010
Location: Portugal
Old 09-18-2012 , 03:07   Re: Gravity to Velocity
Reply With Quote #6

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?
__________________
mabaclu is offline
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 09-18-2012 , 21:36   Re: Gravity to Velocity
Reply With Quote #7

Quote:
Originally Posted by mabaclu View Post
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
__________________
Ayyylmao
malec321 is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 09-19-2012 , 02:55   Re: Gravity to Velocity
Reply With Quote #8

look into the gravity block code, and edit it so it wont reset the gravity when touching trampoline

Last edited by jimaway; 09-19-2012 at 02:56.
jimaway is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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