Player Physics – Leighton Snyder

I finished the player physics lab, and while it’s still rough around the edges, I think it’s a good place to stop for now. There are a lot of things to keep track of code-wise, but I think I was able to get a hold of it eventually.

I was able to add a double-jump (although there’s likely a better way) and here’s how I went about it:

I added two new variables: jump_max for the maximum number of jumps you can take (which I exported so you can edit it quickly) and jump_count for keeping track of how many jumps the character has left.

Jump Max in the Player properties.
I added “jump_count > 0” as a condition for can_jump.
The jump_count resets every time you touch the ground.
And 1 is subtracted from jump_count everytime you jump.

So, here is everything together. I also added the arm to the player (doesn’t follow the mouse yet) and changed how gravity and jump height is calculated so I could get more consistent jumps.

I swear there is sound; it just wasn’t recorded. I’ll fix that one of these days.

Thanks!

Leave a comment