• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Design Friction vs Slope Force (includes demo now)

W

Wayfarer

Guest
I'm having a hard time trying to work out how these two things fit together. Maybe I'm overthinking this or even going about it wrong. I don't know :D

So, in a standard platformer, if you're on a flat surface you have a specific friction value. But what if you're on a slope (in a line-segment based platformer)?

What I've been doing is making the friction loosen up when going down a slope, and tighten up when going upwards (using the slope angle as a "normalised" multiplier to adjust the friction). But something about this feels like I'm overfitting the problem - I can't help but feel I'm missing something obvious. I mean is friction and the slope force actually the same thing? Should I be unifying them into a single factor?

How it currently works isn't too bad, but it feels like too much guess work for my liking.

I probably should observe games like Sonic Mania or Action Henk as reference.

What do you do / think?!

Edit: I'll post an .exe of this tomorrow, perhaps it isn't as bad as I think. I just can't tell... it feels like I'm simulating more forces than I need to be.
 
Last edited:

CloseRange

Member
If you are trying to compare this to real world physics then the friction stays the same. Friction in the real world is directly correlated to the material, a objected doesn't become less rough if its tilted at an angel.
However a ball rolling on a flat plane stops faster than one rolling on a slop, why? Because of gravity. This is also why its harder to stop running downhill than it is running up.
 
W

Wayfarer

Guest
@CloseRange:
Thanks! Reading that cleared my mind; I was loosely aware of how real world physics worked, but at the same time I wasn't going about this the best way.

I guess what threw me off is I'm trying to get some kind of human / ball hybrid and that's where the mixup occured. Like in Sonic and many other games, the player physics can act more like a ball at highspeeds and a human when travelling slower. So that made me think to loosen the friction when going down slopes, but what I really want... I think... is probably to loosen the "friction" when you're moving faster? I'm double-quoting "friction" here because I know it's different from actual friction. Will have to experiment with this.

It does feel better at the moment though after just using a set friction value. In terms of feeling like a "human" going up and down slopes it actually doesn't feel too bad.

I'll post a quick demo in a few hours - maybe sooner.
 
W

Wayfarer

Guest
Here's what I've got so far: Line Segment Platformer Demo
  • Left/Right to move
  • Space to jump

At the moment it isn't very momentum based like Sonic, but I think for general platforming movement it feels quite nice.

Edit: For some reason the .exe export of that is running slower than in GMS. In GMS it runs smoothly at 5000fps (more or less) and the exported version is sometimes stuttering. Does anyone else get that too?

Edit2: Now it isn't stuttering :p

Edit3:
I'm going to make it so when you drop over steep angles you don't hug the ground but rather go into the air. That should make things more natural.
Also, you should jump outwards from steeper walls so you can't climb up them by constantly jumping.

Edit4: Fixed it so you don't hug walls when dropping over angles greater than 45 degrees. Though I do need to make it so you can still jump a few frames after leaving the ground (that way you can go over a hump and still jump even if you've been in the air a bit).

Edit5: Made lots of improvements! Collisions work on all angles, and you now you can run upside-down on slopes with enough speed (so you can do things like loops etc). Haven't uploaded this version yet as I'm still fixing one or two things - but should be able to show it soon. Once I upload that, the last thing will be to take into account sprite_width and sprite_height. Pretty sure I've got an idea how to "fake" those and avoid lots of complicated maths! :)
 
Last edited:
Top