Sign in to follow this  
BastionPlus

WallKick

Recommended Posts

BastionPlus    100
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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this