Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | jjcard |
I am attempting my first project which is started from the 2D tutorial. I added a simple new_game function, but for some reason the CollisionShape2D for the player is still disabled and Mobs can’t kill the player.
This is the ‘body_entered’ method for the Player that shows it’s killed:
hide() # Player disappears after being hit.
emit_signal("player_killed")
print_debug("hit and dying")
#defer so it's not disabled in the middle of a collision processing
$CollisionShape2D.set_deferred("disabled", true)
The method called on the player on new game
func start(pos: Vector2) -> void:
position = pos
$CollisionShape2D.disabled = false
show()
Tried doing $CollisionShape2D.set_deferred(“disabled”, false) but that didn’t work
weird thing is it isn’t disabled in the restart of in the Main class.
func restart():
get_tree().call_group("mobs", "queue_free")
while($Player/CollisionShape2D.disabled):
print_debug("waiting I guess..2")
new_game()
It never prints the debug statement there.
But after restart in the ‘_process’ method in Player, I added a ‘print_debug’ statement if $CollisionShape2D.disabled to find that it was somehow disabled when playing.
The collision works normally in the game before the restart.