How do I keep the char's slide while passing through wall?

0 favourites
  • 13 posts
From the Asset Store
3 different games for kids, easy to edit, mobile ready
  • Hi devdudes! ^_ ^

    My game's character has a sliding movement to pass under narrow walls, similar to the classic MegaMan. However, depending on the starting point of the slide, this movement may stop while the character is still going through the wall.

    What would be the best routine to make the character continue sliding if the move ends when he is under the wall?

    I'm currently using a sprite in the pass-through scenario only via slide, which keeps the boolean variable of the slide active and the direction of platform behavior (left or right) to make the character pass automatically.

    Thanks for the attention and colaboration.

  • Well, how have you coded the slide? Are you able to add a collision test so that the slide always continues until clear of the wall / else slide lasts for the normal duration of the slide?

    I'm speaking vaguely because without more information about how you've gone about this effect it's hard to say specifically what to do. Can you post some of your events?

  • Hi mikehive!

    My character's slide can only be executed during his run (two taps in the directional, which double his speed while pressed).

    The run and slide abilities use distinct boolean variables and the slide uses deceleration to slow the character down gradually.

  • Okay, so what if you set it up so that while slide boolean is true > every frame the player is under the wall the deceleration is set to 0 or 1 (or something really low) > else deceleration set to whatever you have it set at now, so that they move at constant speed until the end of the wall and then begin to decelerate on leaving?

    Haven't tested, but just spitballing ideas

  • Okay, so what if you set it up so that while slide boolean is true > every frame the player is under the wall the deceleration is set to 0 or 1 (or something really low) > else deceleration set to whatever you have it set at now, so that they move at constant speed until the end of the wall and then begin to decelerate on leaving?

    Haven't tested, but just spitballing ideas

    Right, but how will I identify that there is a wall just above the player's character?

    C2 has two routines to identify ground below the player (Platform is on floor) and walls next to him (Platform has wall to left or right), but dont have to something above it.'

  • What about have an invisible collision sprite covering the space under the narrow wall, and test if the player is overlapping it?

  • What about have an invisible collision sprite covering the space under the narrow wall, and test if the player is overlapping it?

    I already did it this way and it worked out. I'm looking for some alternative, like identifying a sprite above the character while the boolean variable "slide" is active.

  • I suppose you could compare the Y coordinates of the player and the wall and check if the ceiling is within 10 pixels or however many.

    OR! This is probably a better idea. Make a small invisible collision object and Pin it a small distance above the player's head. Then you just have to test if that collision object is overlapping any walls when performing slides.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I suppose you could compare the Y coordinates of the player and the wall and check if the ceiling is within 10 pixels or however many.

    OR! This is probably a better idea. Make a small invisible collision object and Pin it a small distance above the player's head. Then you just have to test if that collision object is overlapping any walls when performing slides.

    Both solutions are good, but I would like a mathematical solution, comparing the Y axis of both objects.

    I just don't know how to implement it. If anyone knows specifically, I'm very grateful to post here.

  • This are the rough Basics ?

    https://www.dropbox.com/s/kvqy27upqxkyy ... .capx?dl=0

    If going to use a the deceleration to smoothly stop it sliding. Then i think you have to predict the distance.

    https://www.dropbox.com/s/hpsjdfwjsj9o2 ... .capx?dl=0

  • 99Instances2Go Thanks, dude! It worked very well!

  • Hey,

    I think it's not a good idea to do it with a mathematical solution. Ideas of mike hive are more flexible than a pure reasonning on the Y axis.

    By the way, I'm fund of mathematics, so no offense

    Edit : Oh my god, I didn't notice the very end of the topic. I'm gonna check what suggested 99instance2go :p

  • Hey,

    I think it's not a good idea to do it with a mathematical solution. Ideas of mike hive are more flexible than a pure reasonning on the Y axis.

    By the way, I'm fund of mathematics, so no offense

    Edit : Oh my god, I didn't notice the very end of the topic. I'm gonna check what suggested 99instance2go :p

    Thanks, conker23!

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