Hello. I am trying to replicate Mario Maker's On/Off switches and if the player gets stuck inside the block after it was toggled on, the player just teleports out it. I know this is expected, but I wanted a smoother transition. After looking it up, I found a video replicating the same feature in Godot, but the player, when stuck inside the block, slid out it, much more smoothly. How can I go about doing that?

The black block is the StaticBody, with collisions disabled, the Green square is the ON/OFF Switch; When the player touches it, it activates the StaticBody's collision, teleporting the player outside of it.

Credits to: Mahdi*2007