#Can't get node.

24 messages · Page 1 of 1 (latest)

willow gale
#

(the paragraphs are enumerated accordingly with the images)

1 - Hello there, I'm facing an issue where I can't get the reference of a node for the creation of a onready var. This node is of an animation tree.

2 - I need it for my update animation function that uses another var to work with the animation's blendspace.

3 - The character works with a state machine for multiple states, and so far, with the simple movement for left and right, it manages to get the input var just right from a virtual class, but I still can't get the anim tree node working.

4 - I already have a var for just that on the script for the main player node, but...

5 - When I try to use it in the script for the base state, I get this error:

6 - That is a code that I used for reference for mine's. When I worked with everything inside the main player script, it worked just fine. But I'm unable to integrate in the state machine.

willow gale
#

(actually, paragraph 5:)

cunning solstice
#

can you show the scene tree for where your bottomBaseState script is?

#

cos from whatever node this script is running, there is no child of name "BottomAnimTree"

#

atleast that's what the error message says

willow gale
#

The tree for the scene I'm testing the script

#

The scene for the player itself where the script is running.

#

The "base script" isn't running itself anywhere, but these nodes have their own scripts that extends from that script.

#

example

cunning solstice
#

ok so "idle", "run", "jump" and "fall" extend that base script?
so that would be why the script cant find BottomAnimTree, because it's not a child of any of those

#

you might be wanting to get the parent, $../BottomAnimTree or something like that

willow gale
#

oh, like this?

#

tho I get this

cunning solstice
#

oh i meant in the onready var bit in your 1. paragraph

willow gale
cunning solstice
#

since the script is starting from those 4 state nodes, you cant go directly to the player like that

#

the .. above means to go up by 1 layer

#

hmm wait, maybe it's just $.. then, sorry i forget exactly

#

it might just be easier to set the animtree inside the _ready() function of the bottomStateMachine script, and doesnt tightly couple the state nodes to the bottomStateMachine node

#

so youd loop through the children inside bottomStateMachine, then assign itself to each of the children's animtree variable

#

i guess try both ways and see which one works best for you

willow gale
#

Alright, I'm still trying to get used to working with states and children so that will prob take some time for me to grasp. Thanks a lot for the help!

cunning solstice
#

no worries

#

oh right, instead of $.., if you wanted to get the parent, there was get_parent() method