0 votes

I am attempting my first project which is started from the 2D tutorial. I added a simple new_game function, but after dying and restarting for some reason the CollisionShape2D for the player is still disabled and Mobs can't kill the player the 2nd time around.

This is the 'body_entered' method for the Player that shows it's killed:

    hide()  # Player disappears after being hit.
    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.set_deferred("disabled", false)

Tried changing it from deferred to setting it directly, but got a "Can't change this state while flushing queries" error in logs.

weird thing is it isn't disabled in the restart of in the Main class.

func restart():
    get_tree().call_group("mobs", "queue_free")

        print_debug("waiting I guess..2")

It never prints the debug statement there.

But after restart in the 'process' method in Player, I added a 'printdebug' statement if $CollisionShape2D.disabled to find that it was somehow disabled when playing after restarting.

The collision works normally in the game before the restart.

Godot version 3.3.3
in Engine by (20 points)
retagged by

i also got issue with the disabled properties in the past, i eventually managed to disable the collision by resetting the collision/mask level of the body

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.