Godot Version
4.3
Question
Hello, is there a way to call methods from an autoload script in the AnimationPlayer?
4.3
Hello, is there a way to call methods from an autoload script in the AnimationPlayer?
There is , check the methods track. One of they keys can actually be a function .
Yes, but i wanted to call a function from an autoload script and it doesn’t appear in the methods track.
I don’t know if this help but via script you can add ‘call method’ tracks to animations like this. You might be able to set the path to an autoload, I never tried myself.
func _add_call_method_track_to_animation(animation: Animation) -> void:
var track_idx: int = animation.add_track(Animation.TYPE_METHOD)
animation.track_set_path(track_idx, ".") # Will look for the methods at the root of the scene
var method_name: String = "my_func"
var method_args: Array = []
var at_time: float = 1.0
animation.track_insert_key(track_idx, at_time, {"method" : method_name, "args" : method_args})
I saw your script and i thought of a solution, i can just call a function during the animation that calls a function from the autoload script.
func callPrint():
GameManager.printFunction()
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.