Jump to content
  • Advertisement
Sign in to follow this  
BastionPlus

WallKick

This topic is 2804 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

Greetings all!

I'm new to the Gamedev site, and just thought I'd say hello to everyone before I make my first post. I'm a programmer for a living, but I'm certainly not a game programmer. For fun I decided I wanted to do a shooting 2D platformer that has been going well so far, less one piece of functionality, the WALLKICK! It's become a staple of modern platformers yet I just don't have the psudeocode,alogorithm, idea correct.

for a jump, I increase velocity in the negative direction going towards the top of the screen and while jumping i add a postive velocity (Gravity) to bring my sprite back to the ground only stoping from a ground collision.

while 'colliding' with walls, I make gravity slower, so i get the wallslide going, however when I press jumping firing off code that changes the velocity to that of a jump there is no effect, in fact I stay attached to the wall.

Do i need to make velocity 0 at the instant of the jump? then then jump velocity? I'd love to hear peoples thoughts.

Share this post


Link to post
Share on other sites
Advertisement
I'd do it in terms of forces, from which you can calculate velocity. When the player is on the ground, the force of gravity downwards is cancelled by a force upwards from the ground. You can then alter this second force to move up or down, which avoids having to mess about with gravity - you can keep this constant.
For a jump you apply a temporary force upwards, significantly larger than gravity which will move the player up into the air - once they've left the ground, there is no upward force to counteract gravity and so they start to come down again. To 'wallkick', if the player is in contact with the wall, apply the upwards force as if they were on the ground - this can be made larger or smaller depending on whether you want the player to jump off the wall or just use it to maintain their present height. If they're running along the wall instead of just kicking off it, you can reduce it over time to create the effect of them slipping off the wall the further they run.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!