![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | GilbyScarChest |
I’m working on a 2d platformer and I have it set up in the usual way that when a player shoots an enemy with a projectile, or shoots something that explodes next to the enemy, the enemy dies and it’s CollisionShapes are disabled allowing the player to safely walk through the enemy.
This seems to work fine when it’s the player firing at the enemy, however when the explosion kills the enemy, the CollisionShapes remain active even though the explosion is calling the exact same Dead() function.
here’s the code for the explosion:
func _on_Explosion_body_entered(body):
if "Player" in body.name:
body.Dead()
if "Enemy" in body.name:
body.Dead()
And the enemy’s Dead() function:
func Dead():
is_dead = true
motion = Vector2(0,0)
$AnimatedSprite.play("dead")
$CollisionShape2D.disabled = true
$Area2D/MeleCollision.disabled = true
$Timer.stop() #stops the enemy's shooting timer
It looks like someone is having the opposite problem here Area2D Collision disabled, can't be enabled inside of a signal · Issue #25973 · godotengine/godot · GitHub
Zylann | 2019-08-07 12:58