How can I call functions from a script attached to a child object?


New Armory3d user here,

I have a script called FirstPersonController attached to the Character object. I also have a script called CharAnimationController with the function walkFowards() attached to the Armature object.

I want to call walkFowards() from within FirstPersonController, but I am not sure how I can do this in the code.

Here is my scene hierarchy:

Basically, walkFowards() is just going to play an animation once called.



You can use Object.getChild() to get the object for the armature, and then use Object.getTrait() on that object and pass in the class path to the trait that has the function you want to call before calling walkForwards() on what that returns.

var armature = object.getChild("armature");
var controllerTrait = armature.getTrait(arm.CharAnimationController);
1 Like


Thanks! Ive got it working now. There’s some problems with the animations but that’s a different issue that I’ll figure out later.

1 Like