0 votes

Hello,

I'd like to attach gdscript to a node at runtime with something like this:

var cscript = load( ReVA_PATH_CONSTRAINT )
for i in range( node.get_bone_count() ):
    var bname = node.get_bone_name(i)
    var ba = BoneAttachment.new()
    node.add_child( ba )
    ba.bone_name = bname
    ba.script = cscript.new()

There is no error, but when i print ba.script, the attribute is still to null.
Am I missing something? Or it is simply not the way to do this?

Thanks in advance,

fran├žois z.

asked Sep 19, 2019 in Projects by frankiezafe (86 points)

1 Answer

0 votes

Just found the solution here (with an error):

var cscript = load( ReVA_PATH_CONSTRAINT )
for i in range( node.get_bone_count() ):
    var bname = node.get_bone_name(i)
    var ba = BoneAttachment.new()
    ba.set_script( cscript )
    node.add_child( ba )
    ba.bone_name = bname

I have added the script before moving the object in the tree, to avoid missing events, not sure if it is usefull...

answered Sep 19, 2019 by frankiezafe (86 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.