Godot Version
Godot Engine v4.2.2 stable
Question
Hello !
I would like to ask for help in how I can call the animation player in the game in another script?
The point is that there is player.tscn in which there is an animation player that contains the animations that I would need in another script.
Thanks in advance for the help.
Use Autoloads, search in google that godot autoloads for learn more, otherwise I am mentioning the steps for it:
- Create a script, name it Global
- Go to project settings > autoloads
- Add the Global script in autoloads
- Add a variable player = null in that script
- In player ready function do like Global.player = self
- Now you can use the animation player from another script like Global.player.get_node(“AnimationPlayer”).play()
Also there are many ways like signals, etc