Sending data down to child node

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rayohvv

I have a Player scene with an AnimationTree child, the animation tree has a script to handle its animations, and it has member variables to keep it updated with the player scene.

func send_values_to_anim_tree():
    animTree.velocity_length = velocity.length()
    animTree.is_crouching = crouching
    animTree.camera_pitch = cameraSystem.pitchPivot.rotation.x
    animTree.input_strafing = input_dir.x

This function gets called on the player’s physics process,
is there a cleaner and more orthodox way to do this?

:bust_in_silhouette: Reply From: jgodfrey

You could do this in a number of other ways (singleton, signals, …), but what you show looks reasonable to me - unless updating this from the player’s physics process is way more high-frequency than needed. If that’s the case, you might consider only notifying the child when the values change. But, that’d be more complex and isn’t likely warranted unless you’ve identified the above as a specific bottleneck…