Godot Version
4.2.1
Question
Hello everybody! I’m making a trap block, it should disappear after 3 seconds (conditionally) and appear after 4 seconds (conditionally), but I can’t figure out who to send the signal to, also the IDE swears at the last line.
extends RigidBody2D
var disappear_time: float = 1.0
var respawn_time: float = 4.0
var is_active: bool = true
var spawn_position: Vector2
func _on_Area2D_body_entered(body):
if is_active:
is_active = false
spawn_position = position
await get_tree().create_timer(disappear_time).timeout
queue_free()
await get_tree().create_timer(respawn_time).timeout
respawn()
func respawn():
var new_block = preload("res://Scenes/Death_block.tscn").instantiate()
new_block.position = spawn_position
get_parent().add_child(new_block)
func _ready():
connect("body_entered", self, "_on_RigidBody2D_body_entered")