Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

jump/gravity

This topic is 6154 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok, im about to rip my hair out on this one! it seemed simple enough at first, but, as always my plans back fire! first off for jumping, how can i make it where you just tap the button instead of holdingit down, because right now i have...
if ( buffer[DIK_SPACE] & 0x80 )//Jump/eject
{
        if (Pstate==1)
	{
	      if (ytrans <= -0.3f)
		    ytrans=-0.7f;
	}
	if (Pstate==2)
	{
		Pstate=1;
		ytrans=ytrans-12.0f;
	}
}
 
Pstate is a variable i use to detemine whether the player is in a jet, or walking, Pstate 3 will be for tanks etc, but im not that far, now what i want to do, is make it where they tap space and it increases to -0.7f if they are walking, i used to have it go like this, if (ytrans <= -0.3f) ytrans=ytrans-0.1f; so that it would steadily increase, but they had to be holding space and that wasnt good, obviously i want the same for pstate2 but i just want it to go higher since they are ejecting =) now for my artificial gravity, i just lower ytrans until they are back at -0.3f because i havnt added collision detection yet (on my todo list for tommorow) but, gravity interferes with normal jump (not eject) because with the stead increment i had, it just lowered ytrans right after i incremented it, heres the snip for my gravity, if (ytrans<=-0.6f) { if (ytrans<-0.3f) ytrans=ytrans+0.1f; if (ytrans>-0.3f) ytrans=-0.3f; } note: this isnt called when space is pressed so thats not the prob =P but anyways, it works fine with eject because eject goeshigher than the rate of gravity, im mainly worried about getting jump to be a tap of space instead of holding it, and i want it where if they hold it, it still only jumps once, any of ya know what im talking about?

Share this post


Link to post
Share on other sites
Advertisement
"i havnt added collision detection yet (on my todo list for tommorow)"

Wow. Nice to meet a programmer who can add collision detection in a single day...


Um,. seriously though, this is a big ask. Really, you need collision detection /before/ jumping and similar movement.
That way you can have a constant gravity vector pulling the player down (but he won''t fall through the floor because of your collision detection). Then when the jump key is pressed you give the player an ''up'' push (vector, I guess) so he rises up. But your gravity one slowly cancels it out until he lands back on the ground again.

I hope you understand it, reply if you don''t and I''ll try to make it a bit clearer.

Share this post


Link to post
Share on other sites
Simplier: you need y-speed
when you jump yspeed>0, when you are in the air yspeed-=gravity_factor

and then ytrans+=yspeed

Share this post


Link to post
Share on other sites
hehe i didnt plan on "finishing" collision detection in one day, just pretty much starting it and sorting through the millions of bugs im going to have =P

hmmm, im not too clear on the vector idea, you know of any good vector&grav tuts? what im also going to start tommorow is make it when your in Pstate2 make looking left and right with the mouse actually just rotate the camera left or right while still looking forward (like a clothes dryer) that way to turn the plane you do like half a barrel role then pull up, sound like a cool idea? that way it would also make barrel rolls and sharp banks easier to accomplish.

im gonna take out my artificial grav tonight, and my lame jump =) then first thing in the morning im going to work on collision detection, then if i get arround to it, loading a ms3d terrain model, is nehe''s collision tutorial a good one to use, or is there a better one for me out there? =)

thanx in advance,
dirtypope

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!