Normalizing movement on slopes

hankster112

  • Posts: 27
I've developed a movement system for a 2D Metroidvania that up until now has worked fairly well. However I was only testing it on flat surfaces, and now that I have remembered that sloped tiles exist it's thrown everything out of whack. When trying to walk up a slope, the player's movement is reduced to a crawl and they will slide back down if the button is released. The movement system in this game was built from the ground up (no extensions/starter packs) and probably has a lot of inherent flaws that need to be worked out. Would anyone be able to give me some pointers in the right direction? I can post specific segments/explain other parts if needed.

Luyren

  • *
  • Posts: 2754
https://luyren.itch.io/
In the Utility Pack contained here, there is the "On Ground" behavior, which has an option to "estabilize" actors on solid slopes. This should work as is without alterations to your own code, simply by attaching it to your actors and checking the slope option, or you can open the behaviors and see how it is done, as it has comment blocks showing the purpose of different parts of it.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

hankster112

  • Posts: 27
The ground check system I have checks for:
  • Player's y-speed is 0
  • Player is not actively jumping
  • Player is not grabbing onto a ledge
If any of these conditions are not met, it sets PlayerOnGround to false. Should I be checking for anything else?

« Last Edit: October 27, 2021, 03:57:44 pm by hankster112 »

Luyren

  • *
  • Posts: 2754
https://youtu.be/e6vwZDSLxXg
This video explains what you need for the most basic ground detection. The points you are checking shouldn't really be needed.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

hankster112

  • Posts: 27
I've simplified my ground check like you posted and worked out most of the kinks, however I'm still having some issues. The player still comes to a stop at a 45 degree slope and traveling down a 30 degree slope causes the ground check to rapidly switch between true/false.

Edit: Messed around with friction and speed a bit more and I'm figuring out how to use tile data to change movement speed. However now whenever the player goes up a slope and reaches the top, they do a small hop. How would I mitigate this?

« Last Edit: November 11, 2021, 01:09:20 pm by hankster112 »