Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | fago |
Hi,
I need help with the body_entered
signal of an Area2D node.
In my game I can break an Item with the Sword or with a Projectile. This Item is made like this:
Area 2D
- Sprite
- AudioStreamPlayer2D
- CollisionShape2D
- StaticBody2D
- CollisionShape2D
While Sword and Projectile are made like:
KinematicBody2D
- Sprite
- AudioStreamPlayer2D
- AnimationPlayer
- CollisionShape2D
and:
KinematicBody2D
- Sprite
- AudioStreamPlayer2D
- CollisionShape2D
The Item uses the body_entered
signal. It detects the Sword, that appears when its button is pressed and plays the animation, while it doesn’t see at all the Projectile, which is moved with move_and_slide()
: they collide, but the signal doesn’t get triggered. If I delete the CollisionShape2D node inside the StaticBody2D of the Item, the Projectile passes trough it and signal gets triggered. But I want the Item to be “physical”.
Does anyone know what the problem could be?
Thank you very much!
I solved this with a custom signal in the Item. When the Projectile collides, I take the collider and if this is the Item, I emit the signal.
Anyway, I mantained the other code for the Sword (inverting Area2D and StaticBody2D).
fago | 2018-06-06 21:15