How do I make an object that plays an animation on contact and then takes me to the next level?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nebulabee

I’m currently working on a small platformer game for practice and want to implement an object who, upon interacting with it, plays a small animation (of the character messing with it) and then takes the player to the next level, where they must rinse and repeat until the game ends.

I tried following a tutorial online, but it was made 3 years ago and it doesn’t seem to be working for my game. Any help is greatly appreciated!

:bust_in_silhouette: Reply From: Enfyna

Generally you would use characterbody2d node for your character and for the interact object you can use a area2d node. Then connect the area2d’s body entered signal to your script. In that function you can do the things you listed. First you would check if the body is the player. Then play the animation. Wait for it to end. Then change the scene.

Thank you!! I’m managing to make it work, finally got a reaction from the player character touching the object!

Nebulabee | 2023-06-16 16:48