Solving for Slopes

Galdon2004

  • *
  • Posts: 313
So, I am trying to get slopes to work in my platformer, but am having some difficulty, as the old behavior which used to handle slopes in the version I am currently in appears to be empty. Downloading it from stencylforge also produces an empty behavior. So, I'm not even able to look at what the code used to be to try to emulate it.

Currently, having the game check that I'm not jumping, and that I'm touching the ground, then multiply Y speed by .97 allows me to stand on, and run up slopes with minimal issues; though my character switches into jumping for a moment at the top of the slope, and very slowly slides down still. Running down slopes, however, my character just runs past the slope and alternates between touching the slope and falling which isn't even close to working right. 

from google searching, I mostly seem to be finding threads where it's said that slopes haven't been really figured out, but those threads are a few years old. I am wondering though if some answers have been figured out in the meantime.

Luyren

  • *
  • Posts: 2747
Check my Player Control behavior here: https://luyren.itch.io/luyrens-miscellaneous-stencyl-behaviors
There are comment blocks in both the Update event and the Collision event pointing to the relevant code for slopes.

The jumping at the top of slopes is just physics: your actor being "launched" basically. I have a semi-solid setup in which you use actors for slopes, and that prevents this issue: https://luyren.itch.io/luyrens-utility-pack

My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

Galdon2004

  • *
  • Posts: 313
Thanks, i will give those a look and see if I can figure out a good way to implement them with my current code.

Edit: I actually am hitting a problem right away; the simisolid platform behavior which the instructions say is needed to create slopes requires anything interacting with the slope to have the player control behavior attached to it, which is kind of an issue as I already have the controls programmed for the player and attaching the player controls behavior even with "player control" unchecked causes the player to get stuck in place.

Enemies still "function" with that behavior attached to them, but they do not, for some reason, interact with the slope at all. I do have the slope actor set up with a normal hitbox set to sensor as the instructions say, and the debug draws the line properly.

« Last Edit: April 22, 2020, 02:26:53 pm by Galdon2004 »

Luyren

  • *
  • Posts: 2747
See attachment. Remove those blocks between the comment blocks in the image, at the bottom of the update event. That should enable movement with your own code.

If your enemies are not interacting with the slope, you probably need to check their collision groups, or add a sensor collision just for the interaction with semi-solids. Failling that, set the correct group of the semi-solids in the Player Control behavior for them. And if you have instance customization on for your enemy actors, remember to make the changes directly in the scenes they are in.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

Galdon2004

  • *
  • Posts: 313
Thanks, that allows my character to move. Neither players or enemies can touch the slope though; they move right through it.  The slope is set to the tile group which does collide with players and enemies. The hitbox for the slope is the default square set to sensor and set to "Same as actor type"

Luyren

  • *
  • Posts: 2747
Have you tested the sample game, and compared that with your setup, checked if you are missing anything?
If you use the Player Control behavior for movement, do they still ignore the semi-solids?
It's hard to say what the issue could be just from the information provided. If you are comfortable with it, you can send me the project file for your game via private message and I can take a look directly.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

Galdon2004

  • *
  • Posts: 313
I found the issue while trying to set up the player control behavior to be used. There was a setting down a little ways for which kind of hitbox to look for with the simisolid platforms. I had to do a few changes to adapt the player control behavior to cooperate with jumping on slopes but it seems to be working now. Strangely, at least in the game I'm doing I need to set it two pixels above the tiles next to it, rather than one pixel to allow smooth transitions.