I have a relatively simple state machine as of now, however then I want to pass from state to state I would like to know what the parent is up to.
Is this possible? I am new to godot. I've seen that generally speaking children shouldn't manipulate it's parents, but I don't intend to, I simply want to know what the parent is doing to properly change states.
How to access is_on_floor() method from parent through a child?
newmodels It keeps telling me that the function "is_on_floor()" is non existent. I feel like my problem is trying to access Player node from the child, but I am a bit stumped atm.
- Edited
get_tree() returns the base scene tree, not anything in Player. From your screenshot, the variable "player" should be set to self.
Edit: No, I'm wrong. It could be "get_tree().get_current_scene().find_node('Player', true)" or "get_parent().get_parent()".
duane I tried both, and it continues to insist that the instance is null... Something is preventing me from accessing the Player node
- Edited
- Best Answerset by synchrech
Here's a little test project to show you how I'm doing it. Note that it prints the type and name of the Player object. However, I'm doing the print in _ready(), and at that point I can be sure that all the nodes in Player at least exist. The scene tree is loaded in a particular order, and children are initialized first, so that order may be foiling your attempt if you're setting player too early. I'd set it in _ready(). Also, I'm assuming a lot about the rest of your project, since I can't see it. When you test what you've got now, make sure you're running the game (F5), not the player scene (F6).
Edit: You can look at the actual scene tree by clicking "remote" in the scene tab, to make sure everything is being placed and named correctly.
duane It worked now, I thought using onready was the same as setting something on the ready function... Grave mistake. Thank you so much!