Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Zore |
First thing I want to say is that I’m new to Godot (and game development), so I may be doing a flagrant error.
I was trying to make a simple code to detect a collision between two objects (a character and a coin). I discovered that get_slide_collision only works if the opposite objec is an StaticObject. I wanted something more generic.
After googling for a while, I only found people saying that I should use an Area2D. I’ve used it and it works, but it has issues.
First, I have to duplicate the CollisionShape. Both KinematicObject2D and Area2D need a CollisionShape child. I didn’t figure out how to share the shape between the two. The code works, but duplicating data is wrong.
Second, when the game starts up, the Area2D detects a collision with the player, and triggers it’s signal. So the player detects a collision with itself. It doesn’t have any effect as the player isn’t in the “coins” group and it doesn’t further execute anything, but it shouldn’t happen. An object detecting a collision with itself is also wrong.
So my question is, Is there a cleaner way to detect a collision between a KinematicObject and a non-static object?
Thanks in advance.