The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

Hi, I've just started with Godot this week without much experience at all with coding.

I'm trying to create a simple Flappy Bird style game without using a tutorial to challenge myself with problem solving.

My problem:

I'm trying to get my player (KinematicBody2D with AnimatedSprite and CollisionShape2D) to die when colliding with my pipes (Sprite with StaticBody2D and CollisionPolygon2D) but I can't seem to get it working.

This is my code I have for my user to try and implement this so far but it's not working:

func _on_body_entered(body):
    if body.get_name() == "obstacle":

Any help would be greatly appreciated, thanks!

Godot version 3.2.3
in Engine by (16 points)

1 Answer

0 votes

Just add an area 2d to your bird with a collision shape slightly bigger than the actual collision shape so that it can collide, and then connect the body entered signal. Also, it seems that your obstacles are a sprite with a static body child? I would always use a static body with a sprite child. I may be wrong but it could be since your sprite seems to be the root, that you named it an obstacle, but the body that the player is colliding with is actually the static body, which could have a different name and wouldn't trigger anything. I hope these help! If not, hopefully, I can help you better.

by (599 points)

After a bit of experimenting it finally worked, thank you for the help and advice!

Of course! I didn’t know if I had worded the answer well at all so I’m glad it helped!

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 Frequently asked questions and 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 [email protected] with your username.