How to set a fixed path towards goal (Castlevania style stairs)

1 favourites
  • 7 posts
From the Asset Store
Single Track kit that includes wav files for the Beat, Lead, Sub and the MP3 loop.
  • (Reposting this since I can't for the love of me find the original one I wrote yesterday)

    Hi everyone! I've been getting my hands dirty with Construct for a while now, but lately I've been working in my first big thing: a classic Castlevania style game. All the movement, enemies and small things are all set and working nicely, but I had to rework the events I had for the Stairs since it's not very efficient while creating levels (it requires a lot of tweaking in order to trigger things correctly, jump-thru on diagonal objects is a mess).

    What I'd like to learn is how to move a sprite towards a fixed path with player input The video here https://www.youtube.com/shorts/vtrYWJCSFD0 is what I'm trying to achieve, but translated into Construct.

    In case the link doesn't work, the person speaking says that in order to emulate Castlevania-like stairs you require 2 triggers (BottomStairs and TopStairs). After you press UP if you are overlapping BottomStairs or DOWN if you are overlapping TopStairs, the Player instance gets stored in a variable object. Pressing UP or DOWN while being on the OnStairs state Adds or Substract to a Float variable that determines the position you are in the stairs (0=Bottom;1=Top; everything in between those values= the stairs themselves). After reaching either Trigger again, you return the Player to their regular state.

    I know 8 Direction is a nice behavior to consider but if the thing addressed in the video is easier to achieve I would like to try it. Biggest problem I have is how to move the Player in a fixed path without using solid objects as platforms, it just doesn't work as I want to.

    Thanks in advance!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks a lot for the help dop2000! I'm taking a look at it and it works almost exactly as what I'm going for (I'll just add the triggers at the top and at the bottom of the stairs as to prevent bounding issues. One question though: what is the value Padding local variable making reference to?

  • I don't know how to explain it :) I guess an 'offset' is a more accurate word.

    It's half of the character width, try changing it and see what happens.

  • Ooooh I see, thanks! I've been playing around with the values and different stairs sprite sizes and it works nicely, now I'm trying to see if I could go even further beyond and make it so it moves a fixed amount of steps in the stairs at a time like in the NES games (I tried to make the Player sprite move towards the stairs if you are not close to the trigger too but that's honestly too many events for such a small thing).

  • Sorry to bother again, but I'm trying to mirror the stairs lerp and unlerp action to make it work from the right but I don't quite understand what I'm doing wrong.

    The original one you wrote was:

    "Set Player Y lerp(Stairs.BBoxTop, Stairs.BBoxBottom, unlerp(Stairs.BBoxRight-padding, Stairs.BBoxLeft-padding, Player.X))"

    Should I just change the order of the lerp and unlerp instances or make something negative to make it go from bottom right to top right? Sorry for not getting it, angles in construct always make me go crazy.

  • Forget what I said, I just had to change the placement of the BBox. Now it works just great, thanks a lot!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)