Godot Version
4
Question
Hello, I’m trying to make a sort of “puzzle”, and when the player activates a tile, a “door” is removed and if the tile is deactivated that door reappears again. I’m doing so by removing and adding the node that corresponds to the door. The problem is, it works when the scene starts but if I activate and deactivate the key tile, the CollisionShape2D reactivates but does not collide with the player. Here’s the code:
@onready var door: StaticBody2D = $PuzzleDoor
var puzzle_parts: Array = []
var total_parts: int = 0
var completed = false
func _process(delta):
if total_parts == 0 and !completed:
$PuzzleDoor/CollisionShape2D.disabled = true
completed = true
dooranim.play("disappear")
func _part_activated(status, part):
if status:
total_parts -= 1
else:
completed = false
total_parts += 1
add_child(door)
$PuzzleDoor/CollisionShape2D.disabled = false
dooranim.play("reappear")
pass