![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | eviking |
I have a platform that I am able to have it disappear after 1 second, and I have used a timer to do so. Now I am trying to make that same platform reappear. I am not sure if I am approaching this the right way.
Stage script:
extends Node2D
var hiding_plat = preload("res://Scripts/DissappearingPlatforms.gd")
var x = 1
func _ready() -> void:
pass # Replace with function body.
func spawn_plat():
if x == 1:
var new_plat = hiding_plat.instance()
new_plat.connect("dissappear")
get_tree().get_root().call_deferred("add_child", new_plat)
new_plat.set_position(get_position(), Vector2(21, 6))
DissappearingPlatforms Script:
extends TileMap
var z = 1
func _ready() -> void:
$Timer.start()
pass
func _on_DissappearingPlatforms_visibility_changed() -> void:
pass # Replace with function body.
func _change_z_back():
z -= 1
func _on_Timer_timeout() -> void:
emit_signal("dissappear")
z += 1
_change_z_back()
queue_free()
pass
The random z and x variables are just placeholders (I was tinkering with unsuccessful loops). Also I am aware that func _on_DissappearingPlatforms_visibility_changed() does nothing. That was a preexisting signal from Godot that I connected from the Node tab, I just don’t know what logic I would put in there to ideally make the platform invisible (the most straightforward way), instead of using que_free at the end of the timer (my platform is lost after this executes). Thanks for any help.