|Topic was automatically imported from the old Question2Answer platform.
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.
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:
if body.get_name() == "obstacle":
Any help would be greatly appreciated, thanks!
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.
After a bit of experimenting it finally worked, thank you for the help and advice!
ben2420 | 2021-02-03 20:46
Of course! I didn’t know if I had worded the answer well at all so I’m glad it helped!
djmick | 2021-02-03 21:08