(SOLVED)Layers make my character disobey the laws of the universe and just float

nam man

  • Posts: 31
Ok so I'm trying to make a 2D platformer and added tiles to a Tile Layer for the background and put my character on a different layer with the tiles i actually want him to jump on. However when I try playtesting the game and dropping him from above, he is stuck there and refuses to fall down or obey gravity. Then I try deleting the background Tile Layer and he falls down just fine. So I think the Tile Layer I'm trying to use as a background is being counted as an actual tile by my Actor for some reason, but when I watched that one video on Youtube about how to make a basic platformer he did it just fine and the actor treated the other layers as untouchable entities. I don't get it, I just want him to jump and obey gravity and treat the other layer as a background layer. Can I not use tiles as background after all? If there is a way, how do I do it without my character touching it?
Also as an extra question are there any behaviors you'd recommend from Stencylforge for platforming? Because the "Jumping" and "Platformer Behavior Pack" or whatever the one with 10k+ downloads was called both failed for me, but if nothing else I can just make my own. Thanks in advance.

« Last Edit: October 12, 2019, 02:26:14 pm by nam man »

Luyren

  • *
  • Posts: 1798
[...] added tiles to a Tile Layer for the background and put my character on a different layer with the tiles i actually want him to jump on. However when I try playtesting the game and dropping him from above, he is stuck there and refuses to fall down or obey gravity.
Your background tiles have a collision box. You can remove them for those specific tiles. In the tileset's page.

Quote
Also as an extra question are there any behaviors you'd recommend from Stencylforge for platforming? Because the "Jumping" and "Platformer Behavior Pack" or whatever the one with 10k+ downloads was called both failed for me, but if nothing else I can just make my own. Thanks in advance.
Open any actor, click "Add Behavior", go to "From Your Library > Control" and select the "Jump and Run Movement" behavior.
I have my Stencyl resources available here: https://luyren.itch.io/

nam man

  • Posts: 31
Thanks for the tip, removing the collision worked but my character still can't jump despite me using the Jump and Run movement. My character is affected by gravity which is 85.0 vertical. The only other behavior I have given him is Cannot Exit Screen. Is there a way to fix this?

nam man

  • Posts: 31
Update, I thought maybe it was because of some other actor behaviors I added earlier affecting it despite being deactivated (2 way horizontal movement) so I removed them but now the character is completely stuck in place while playing the walking animation. He can neither jump nor run.

nam man

  • Posts: 31
It got weirder- I remade the level from scratch and now he can only move if I press jump and the left/right arrow key at the same time, causing a side jump (or whatever you'd call that). Pressing the left/right key does not move the character by itself though. Wh

Luyren

  • *
  • Posts: 1798
Remove every other behavior/actor event in your actor, and post a screen shot of your actor's behavior tab, with how you configured the behavior for that actor. Most likely it's a configuration error, but no one can tell for sure unless you provied more information.
I have my Stencyl resources available here: https://luyren.itch.io/

nam man

  • Posts: 31
Here's a screenshot. The part that's cut off is just animations and Jump Animation while falling, which I have ticked to Yes.

Luyren

  • *
  • Posts: 1798
I just tested that behavior and had no problems at all, so it's likely not something with the behavior, but something else. You can try:
1- Removing all background tiles. They might still have collision boxes you might have missed.
2- Change your actor's physics settings. Set it's friction to 0, for instance.
3- Lower the gravity if you don't want to have 0 friction. I always use 50 and 0 friction on my actors, and handle slowing down via code.
I have my Stencyl resources available here: https://luyren.itch.io/

nam man

  • Posts: 31
Thanks so much, setting the friction to 0 helped it work properly! The animation is still kind of broken though because he seems to keep slipping to the left, moving infinitely. How do you make him stop slipping and just move horizontally and stop when the key is no longer pressed?

Luyren

  • *
  • Posts: 1798
It is slipping because of the 0 friction. That behavior doens't have a sowdown code, so you have it code it yourself. It is a simple setup though.

1- First you have to check if the left and right keys are not down.
2- If that condition is met, multiply the X speed of your actor by a number between 0 and 1. If you multiply by 0, the actor will instantly stop. If you want a slight slowdown, multiply it by 0.5 or 0.95. The bigger the number, the longer the slowdown will be.

If you rather try setting the friction again, you could try setting it to a low number, and increase the "Maximum Running Speed" attribute, and try to find a balance where you get the slowdown you want, and can move your actor.
I have my Stencyl resources available here: https://luyren.itch.io/

nam man

  • Posts: 31
It's working now, thank you very much!  :D