Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Thank you for the review. Yes, The player was intended to able to jump when it was 1 tile above ground. That was made to be able to make the controllability of the player better (It would not feel great if you had to be pixel perfectly on ground).

That is pretty cool! Not many people do... anything like that. 

I remember that's how I used to do it, but I realized that it was too inconsistent, and would result in the player jumping higher than I would want them to.
I figured out a more consistent and better-looking version, where instead of checking if I jumped a few pixels off the ground, I would check if I jumped at all, and store a number into a variable(like... 4 frames. I'm not sure what you unity users use). The jump code would be activated by that variable > 0 instead of an input check. That would make it so if that variable is more than 0, if you are touching the ground, you would jump immediately. Every tick, I would subtract 1 from that number, and now we have a system similar to the previous, but it naturally takes gravity into account, and it looks better because we wait until we touch the ground, then jump.

Here's what it could look like in code:

//beginning of tick
if (input.jump) {
    jumpBuffer = 4;
}

//wherever your jump code is
if (touching_ground() and jumpBuffer > 0) {
    jumpBuffer = 0; //this is to prevent unwanted jumping
    //jump code
}

//end of tick
jumpBuffer -= 1;

Thanks for the code part, I actually used unitys Physics2D.OverlapSphere, it was more efficient and had better results in testing. 

(+1)

Btw I'm now on my crap computer again. 

Very well done with the optimizations!