0 votes

How do I fully control the parent node with a script attached to the child node? Like how do I get the parent node to run code that is in a script attached to the child node, as if the code belonged to a script attached to the parent node( even though that’s not the chase)?

Godot version Godot 3.5
in Engine by (24 points)

It's hard to say based on the limited info provided above, but I'd guess there are likely much better ways to solve whatever issue you're working on. Perhaps with some more details about what you're really trying to solve here, someone can offer a better solution.

I'm trying to make a state machine with a node hierarchy.

1 Answer

+1 vote

You can use get_parent() to call functions and get variables from the parent node

print(get_parent().name) # Prints the parent's name

print(get_parent().rotation) # Print's the parent's rotation

get_parent().scale.x = 2.0 # Sets the parent's scale's x coordinate to 2.0
by (731 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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.