Use a Call Method Track in the animation to call the Object method set_script().
https://docs.godotengine.org/en/3.5/tutorials/animation/introduction.html#advanced-call-method-tracks
https://docs.godotengine.org/en/3.5/classes/class_object.html?#class-object-method-set-script
attaching a script to an object
metr1x so?
What does that mean?
DaveTheCoder in the animation, I called a method from "Player" called "set_script()"
on the right, you can see that I added the value "player.gd"
explained how he could
I can't tell whether you're doing it correctly from a picture. Just follow the documentation.
DaveTheCoder followed. it didn't help.
- Edited
If it's a call method track then I think you should be calling an actual method not just a script. You'd create a method in the script that would in turn call the set_script() with relevant parameters on the relevant node. Without actually testing it over here and off the top of my head at least.
nevermind, looking at the docs I think you are doing it right enough. Perhaps the type is an issue or something like that. Whats the warning/error at the bottom in the yellow tab there?
- Edited
Megalomaniak there's a warning in the player's script, nothing like
that, everything works
- Edited
I had some trouble getting custom scripts attached to my root scene. Maybe this will be of help - this is how I do it:
var script_manager_scene = load("res://scenes/rootScene/ScriptManager.tscn")
script_manager = script_manager_scene.instance()
add_child(script_manager)
var new_script = GDScript.new()
new_script.source_code = custom_script_text # this is your custom script
new_script.reload()
script_manager.set_script(new_script)
script_manager.set_process(true)
Note the line 'new_script.reload()'. I think I found in my initial attempts if I had this in the wrong place and it broke the setup.
Also I set this up on the first process tick of my scene. It probably works just fine in _ready but I needed to do this for other reasons.
For debugging make sure you've got the script working when hard coded (placed normally in Godot) before attempting the dynamic load.