Jump, slopes and matter control


Hello again!

Yesterday I've been working on the most important issues in a game: core mechanics. I love to work on these kind of issues, each time I manage to fix these kind of bugs, and a player comes and play again, they usually see and feel the improvement almost immediately they start playing, and praises the developer for that.

So there are 3 changes I've been working on so far

Jump logic (again)

Last time I worked on this in 2018, I had to refactor all the jump logic, as I wasn't understanding correctly how to handle code that goes in FixedUpdate and code in Update functions.

To give a quick summary of these MonoBehaviorevents in Unity3d : in Update functions, you must place code that needs to happen every frame, but frames rate can change depending on how the game is performing, so it's suitable for code that needs to happen whatsoever but not for stuff that needs to happen in a specific moment, like physics behaviors. On the other hand, FixedUpdateis going to handle code that executes code every specific time no matter if the PC is performing good or not.

This was helpful to help me understand what was I doing wrong, and I thought I could finally say that my jump mechanics were clean and superb.

I was wrong

See, the mechanics are mathematically right, but in practical terms, for some reason it doesn't feel right...

The issue that has been reported is that the jump button is unresponsive some times, specially in moments where there is too much action and requires fast response from players (play or watch in gameplay videos for levels 2, 4, 5 and probably 6)

But I've been trying to see frame by frame in Unity jumping multiple times, and every time the jump key is pressed, user jumps! Unless he is not in the ground, obviously, he shouldn't jump until player reaches ground.

Well... the root of this issue is not that obvious.

It happens that players orders to jump and game's response doesn't match with player's mind on the jump order, it's like our brains know we are going to be in the ground any time soon, milliseconds soon, but brain filter this information, telling the player that he is actually on ground already, so player presses the jump button expecting character to jump, but he is not mathematically on the ground yet, so he won't jump, therefore the jump button feels unresponsive.

If there is something I've learned in this game development world is that if something feels correct, then it is correct, mathematical correctness matter, but doesn't matter more than what does the player feel.

Besides, I noticed that a lot of platformers and metroidvanias are already doing this hack! Including one of the indie platformers with the best controls you could find: Celeste

So I've been working on a logic to improve jump by queuing the jump order if the character is a few pixels away from landing to ground, then immediately when he lands, character would perform the desired jump

I'm still working on this tho, this weekend would be the first one in weeks I would be able to dedicate fully to Matter.

Slopes

I didn't like it when character goes in a slope, and if player is not controlling or doing any input, player simply slides down the slope, like a rolling ball... 

I needed to fix this, this would give more control to the player in some kind of levels (levels 1, 3, 4 and 6 have slopes, being the longest ones in level 1 and 3)

In theory if I wanted a mathematical solution, I would have to rely strictly on Unity physics, and play with friction. The thing is: I cannot do that since the main character is not a physically realistic item, its a capsule that doesn't rotate (I assigned it a frozen rotation), and there is no object in the real world that has the shape of a capsule that wouldn't rotate if put from the rounded parts, it would fall and roll... so I can't expect realistic behaviors for unrealistic objects.

So I had to do some tricks and hacks... I tried using joints, it ended up being too complicated, then I tried changing the rigid body type when there is no input, but this had unexpected behaviors, for some reason the character now was able to trespass the ground he was standing over, and fall onto -infinity.

The trick that... did the trick, was freezing X movement when there is no input and player is grounded. This worked fine, but I feel this requires testing, as now if this player is in a slope and he receive an external force (a ball pushing him or a bomb exploding around him), character would receive damage, but won't move... I don't feel this is super wrong, but it could give me an unexpected bug in the future.

I'll leave that to my fellow players.

Matter control

For this one I made 2 changes:

  • If player falls from a huge height but falls onto Matter rather than to ground, the damage he receives would be less, same applies to rocks that falls onto matter, this would give more control to players, make the game feel less punishing and make some puzzles easier to solve
  • I made the platform colliders a bit wider, this tuning would hopefully help players to have more control when standing over matter when jumping to it (with the cost of looking quite unrealistic, floating over the air around matter)

With these 2 updates, I'm looking for player to rely more on matter, I want the matter he uses to be a friend, not something to avoid, or to prefer not to solve puzzles using it, the only thing I want players to be aware of is not to use too much matter, for that I got another fix that would be incoming in the next development round.

See you around!

Join our new Discord server and let's build a gamers and developers community! 

Get Matter

Leave a comment

Log in with itch.io to leave a comment.