0 votes

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?

in Engine by (48 points)

1 Answer

0 votes

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.

by (10,311 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.