|Attention||Topic was automatically imported from the old Question2Answer platform.|
I’m learning Godot after switching over from Unity, and one thing that I can’t figure out how to accomplish is collision detection. In unity, there was a function that would be called upon each collision, that would allow you to manipulate the colliding object.
Basically, I have a KinematicBody2D player, and I want to be able to call a ‘die’ function when it touches a StaticBody2D I have. There are multiple StaticBody2Ds that I want to detect. In Unity, I was able to place tags on all of the bodies, then check that tag on collision, but I can’t figure out how to detect collisions at all, let alone any information about the collided body.
Here’s the script I have attached to my player:
func body_enter(body): print("Collision") if (body.get_name() == "Lava"): print("Ouch!")
Here’s my hierarchy, if its offers any help: