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.

  • newmodels replied to this.
  • 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.

    synchrech

    Doing updates from another node to another node is just fine.

    From the direct child node I would use.
    self.get_node("..").is_on_floor()

    Godot using gdscript is very flexible.

      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.

      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 🙁

        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!