2D Platformer demo, enemy adjustment

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

I used the demo, ‘Dynamic Character Controlled 2D Platformer’ as a base for my platformer.
The enemy there uses some Raycast 2D algorythm to detect where it’s walking.
I need the enemy FLYING, not on the ground.
How can I adjust the ‘Enemy’ scene to make it fly above the platform\ground, not sticking to it?

:bust_in_silhouette: Reply From: njamster

Are you referring to this demo? Because there is no demo called “Dynamic Character Controlled 2D Platformer”… If so, add the following lines to the enemy script:

if $DetectFloorLeft.is_colliding() or $DetectFloorRight.is_colliding():
    linear_velocity.y = 0

before the line containing the call to move_and_slide. This will disable gravity when one of the two downward pointing rays collides with the ground.