#Create the mechanics of Mario sliding down the flagpole

11 messages · Page 1 of 1 (latest)

proven aspen
#

So, essentially, I want to recreate Mario being able to slide down the flagpole like in the original Super Mario Bros. I have the flag and the flagpole made as two different scenes, with each having an Area 2D and a collision shape to detect Mario.

The thing is, I don't know how to go about coding this mechanic, and looking at other similar Godot projects confuses me even more.

All I want for the end result at this point is for when Mario touches the flagpole's Area 2D shape, for the flag itself to slowly drop down as Mario slides down and changes to his "climb" animation.

gloomy perch
# proven aspen So, essentially, I want to recreate Mario being able to slide down the flagpole ...

Here’s a simple way to break it down:

  • Make a scene with the flag and flagpole sprites put together
  • only give the flagpole collision, the flag doesn’t need it
  • also in that scene, add a sprite of sliding Mario on the pole. Just a sprite. Make it invisible.
  • give the scene a script called Flagpole
  • connect the script to the collision Area2D’s body_entered or area_entered signal
  • when a body collides with the pole, if it’s Mario, make Mario invisible and then show the sprite of sliding Mario. Set sliding mario’s Y position to match the real Mario.
  • Create two tweens that move both sliding Mario and the flag to the bottom of the pole.
  • When both finish animating, you can call some other function to do something else
proven aspen
gloomy perch
#

I do think a tween will be useful for at least the flag itself since it’s not worth making the flag a physics object scratch that, we can use AnimationPlayer

proven aspen
ebon patrol
#

If its the end of level, you could go the easy route. Delete Mario and replace it with a sprite only version that just shows him sliding down and exiting the stage.

#

There's no need to overthink things as long as the end result looks good

gloomy perch
#

The very easiest way to make Mario slide nicely is with an AnimationPlayer on the flagpole. You can give the flagpole a child Node2D called MarioPosition and when animated, move it down the flagpole. Then when Mario hits the flagpole, tell Mario to enter a sliding state where he moves to the global position of MarioPosition each frame and does nothing else, and play the flagpole animation

ebon patrol
#

Also, I'd instantiate it in only when needed. No point in unnecessary processes