Weird Stairs Issue

Started by Max, December 22, 2018, 08:02:41 PM

Previous topic - Next topic
Hey guys, just downloaded 1.6 and I've got a weird issue.

It seems like platform stairs won't push the hero up a level unless you hit them EXACTLY straight on. For a staircase only 16px wide, this is no problem, but if a staircase is wider, the player might be moving up the stairs straddling two tiles- in this situation it seems like the entities act like a wall.

I've attached a gif that hopefully shows that's going on better, and a couple screenshots of the way the tiles are laid out.

Hopefully I've just been putting stairs together incorrectly this whole time and it's not the first post-release 1.6 bug?


I think this problem is not new in 1.6, is it?
I have never considered putting 3 stairs next to each other like this. The hero can only use one of them at a time, so the behavior is expected.

2 solutions:
- You could try making a stairs entity of size 48x16, because in 1.6, all entities can have any size. But for stairs you can only change the size from a script, and more importantly, it was never tested.
- Do you even need a stairs entity at all? You can use sensors instead to change the layer of the hero.

It  actually is new to 1.6. I just opened up an old version of my game in 1.5 and there's no issues, tried the same staircase. I wonder what changed that it stopped working?

I'll figure out sensors then. What is the behavior of stairs besides some code like:
Code (Lua) Select

function stair_sensor:on_activated()
Hero:set_layer(hero:get_layer() +1)
end


Is forcing movement on the hero important, or if you don't make the hero move also will they just fall right back down immediately. Well, I guess I'll try it after I make some dinner and figure that out, lol

Here's the results of using a sensor that does

for sensor in map:get_entities("stair_sensor") do
  function sensor:on_activated()
    hero:set_layer(hero:get_layer() + 1)
  end
end




Has anyone used sensors to move up layers and not had an issue with tiles on the upper layer overlapping the hero? How did you overcome that?

Also, just an observation from experimenting with the way stair entities work between 1.5 and 1.6- even if you just put a stair in the middle of an empty field in 1.5, you don't have to be perfectly aligned with it for the stair action to work. But in 1.6 even if a stair in the middle of a field, you have to be perfectly lined up with the tile for the stairs to do their thing.

This tutorial explains how to change the layer using sensors: https://www.youtube.com/watch?v=bXQ7WGK8kvg

Here's my solution in VOADI: https://gitlab.com/voadi/voadi/blob/master/data/maps/overworld.lua#L63-78

  do
    local sensor = map:get_entity("bridge_1")
    function sensor:on_activated()
      local x, y, z = hero:get_position()
      hero:set_position(x, y, 1)
      log("Hero moved to L1: ", hero:get_position())
    end
  end
  do
    local sensor = map:get_entity("bridge_2")
    function sensor:on_activated()
      local x, y, z = hero:get_position()
      hero:set_position(x, y, 0)
      log("Hero moved to L0: ", hero:get_position())
    end
  end


Here's how it looks on my map:



And the same spot with layer 2 hidden:



Would be even better to encapsulate this behavior into a custom entity that automatically creates the needed sensors.
RIP Aaron Swartz

Oh sorry, I think I replied before fully understanding. Also I should have used hero:set_layer which I didn't know about.

I don't have this issue in my game, but my character sprite is also only 16px tall.
RIP Aaron Swartz

The functions entity.get/set_layer are new in v1.6, so it is normal that you didn't know that one.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

I forgot to mention, in my example I also have an invisible platform on layer 1 so the hero doesn't fall through once the sensor lifts her up.

I need something like this again so I'm working on creating a script to make it happen automatically.
RIP Aaron Swartz

We should have mentioned the tutorial of @ffomega related to this (in the Bridges section):
http://absolute-hyrule-tutorials.solarus-games.org/
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

Thanks guys. I followed Christopho's tutorials, and now I've got it so I only need five tiles which I can copy from my debug map each time and the event is handled with metatables, which isn't too bad. However it still feels a little hacked together, since a function as basic as changing layers needs such a complex solution when I could just use stairs before, haha.

But I never liked how the automatic stairs took control away from the player so that's nice that it addresses that too! Now to just do this for dozens of stairs in my game, hahaha........

At the very least, you can create a custom entity that calls map:create_custom_entity() and automatically creates the two sensors and the invisible tile wherever you place it.
RIP Aaron Swartz

What's a good idea, Alex! It could get the width for the stairs from it's own width, then create the sensors and invisible platform at it's coordinates. Good thinking.


Anyway, I was looking at the change log for 1.6 on the website's blog about the release, and saw this line:
Quote
Fix stairs activating when the hero is not exactly aligned.

And realized that's exactly what changed. Is there any way to un-fix this so I can make the behavior of my stairs back how it was?

The old behavior was a bug. But did you try to make a single stairs entity with a size of 48x16? (You need to do it from a script)

January 01, 2019, 09:09:28 PM #14 Last Edit: January 01, 2019, 09:12:13 PM by Diarandor
Quote from: Christopho on January 01, 2019, 04:26:37 PM
The old behavior was a bug. But did you try to make a single stairs entity with a size of 48x16? (You need to do it from a script)
I guess it will be possible to resize stairs in future versions of solarus, right?

If he needs to resize the stairs from scripts, the best way is probably to define the size using custom properties in the editor, and re-define the event "stairs_metatable:on_created()" to use those custom properties to resize the stairs when they are given.
Or even better, maybe he should use custom entities that auto-replace themselves with stairs of the same size, so that he can resize them and see their size in the editor.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."