|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
nagne |
In other scripts, i wanna use updated var values in “Player.gd”. So i was setting autoload. But i got error in Player.gd
How can i solve this problem?!
|
|
|
 |
Reply From: |
crossbito |
Hi, maybe you could try adding “await” to your variable like this:
@onready var animationState = await $AnimationTree.get("parameters/playback");
Alternatively, you can set the variable in the _process function because maybe you are using your script in an object that doesn’t have an AnimationTree:
@onready var animationState=-1;
func _process(delta):
if(find_child("AnimationTree") && animationState==-1):
animationState = $AnimationTree.get("parameters/playback");
I hope it helps!
If not using autoload, is there other ways using var to other scripts?!
Finally, understood. I didnt think that is about all the other objects. So i wanna know other ways. For example, i wanna use from var in “A.gd” to “B.gd”,s var. And if A’s var is changed, B’s var also changed too. Not use autoload. How can i do this?! I was googling, but couldnt solve this. In “load” or “preload” coding way, i can load inital setting var but i cant load updated var values. Plz help me.