Why does the Sprite2D become invisible when parent monitoring is set to false!?

Godot Version: 4

Question

I have a Ship which has this child:

$ShipBody (Area2D)

$ShipBody in turn has 2 children:

$Sprite2D and $CollisionPolygon2D

The ship won’t be removed until 2 seconds after current_health <= 0

During those 2 seconds, the ship should no longer monitor collisions .

But, in each of these ways that I’ve tried, the $ShipBody/Sprite2D (or perhaps the whole ShipBody node) becomes invisible.

This is quite unexpected.
I’ve worked around this by putting the collisionpolygon into it’s own Area2D and make the Ship a Node2D instead. But I still think it should work the other way since collisions and visibility should be independent. So…
Why does it happen?

I tried this:

func take_damage():
  if current_health <= 0:
    $ShipBody.monitoring = false
    tween.tween_property($ShipBody, "modulate", Color(4, 2, 1), 2)

I also tried this:

$ShipBody/CollisionPolygon2D.set_disabled(true)

And this:

$ShipBody/CollisionPolygon2D.set_deferred("disabled", true)

you can disable the

1 Like

Yeah I did that first and the exact same thing happened. :sweat_smile:
I’ve updated the post with that detail too.

I just read your thread again, can you set the sprite as a child of the ship instead of the Area2D

The Sprite2D needs to rotate with the ShipBody. There are other parts that need to remain their orientation rotate but are part of the ship.

How about setting the ShipBody as a Node2D and creating another Area2D as a child of the ShipBody

That works and solves the How. Thank you!

However, I still think that is unexpected. Collisions and visibility should be unrelated as far as I understand it.

As far as I know, every time a node asks for something (the triangle yellow symbol with the “!” icon) the things it asks for become part of the node

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.