Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Nils |
Hello,
i have the following code:
extends Node2D
var t
func _ready():
t = 1
func g():
t= 3
return t
func _physics_process(delta):
print(t)
The function “func g()” will be activated of a signal during my game. But after it activated, “t” has the values “1” and “3”, which i could see, because i print “t” all the time with the function " func _physics_process(delta):" . How is it possible, that “t” has only the value “3”, after “func g()” is activated?
Thanks Nils
ready()
is called once at the start and sets the value to 1
. When you call g()
that will overwrite the value previously set by ready()
and set it to 3
. From then on the value will continue to be 3
unless it is changed by another function. t
will only ever be one value. It won’t be 1
and 3
.
i_love_godot | 2019-12-21 00:38