- Edited
Hi, I'm trying to toggle camera shake by putting the set_process function whin a custom function. When I call this function in the main script, I use yield to make sure the function starts working. Then I found that my main process still hanging after the signal was emitted. The weird thing is if I put a one-second yield between set_process and emit_signal function, everything working just fine. How do I fix it in the right way?
Main Script:
extends Node
func _ready():
var ss = SubScript.new()
add_child(ss)
yield(get_tree().create_timer(1), "timeout")
ss.send_job()
yield(ss, "start_working")
print("Start working!")
Sub Script:
extends Node
class_name SubScript
signal start_working
func _ready():
set_process(false)
func send_job():
set_process(true)
# yield(get_tree().create_timer(1), "timeout")
emit_signal("start_working")
func _process(delta):
#Do Camera Shaking etc.
pass