How to make player fall down the screen when colliding with enemy just like in Mario games?

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

I tried using Area2D on enemy to detect player entering it and then disabling player’s CollisionShape2D but it doesn’t seem to be working.

:bust_in_silhouette: Reply From: VitusVeit

You don’t need to use physics, just create a bool falling, and in physics_process add:

if falling:
     if position.y >= OS.get_windows_size().y:
           falling = false
           #Respawn the player, or just remove a live
     position.x -= 100 * delta

And on collision with the Area2D set falling to true

Thanks, you helped me again! Took me some time to get everything to work properly, though

randomguy | 2022-04-25 14:43

Working with collision and physics is always hard, but don’t worry, with time it will be a easy task!

VitusVeit | 2022-04-29 15:18