Now this sounds simple, cause it should be. To get a node I can just do: $path/to/node.
Now this is exactly what I am trying to do.

So basically I am trying to get a node based off of a base path and a variable.

var startPo = get_node('$Weapon/FirePoints/'+startPathName) # and yes the node does indeed exist

Now this should work (or so I assume) but well, it doesnt.
Luckily enough I do get an error but no matter where I looked could not find a way to fix it, anyone know?
E 0:00:01:0404 player.gd:97 @ _process(): Node not found: "$Weapon/FirePoints/M1911" (relative to "/root/hub/Player").

Thanks!

  • xyz and Jesusemora replied to this.
  • Frodev When using paths as strings drop the leading $ symbol. It's used only for path literals.

    Frodev When using paths as strings drop the leading $ symbol. It's used only for path literals.

      Frodev emm... $ does get_node, it shouln't be in the path. valid paths are:

      get_node("Sword")
      get_node("Backpack/Dagger")
      get_node("../Swamp/Alligator")
      get_node("/root/MyGame")

      https://docs.godotengine.org/en/stable/classes/class_node.html#class-node-method-get-node

      xyz
      Ok well that solved that problem, anyhow once I actually get said node (which is a Marker2D), it errors anytime I try to access its position property, why is this?

      Invalid get index 'Position (on base: 'Marker2D').

      Also thanks for all the help you've been giving me!

      • xyz replied to this.

        Frodev The property is position, not Position. GDScript is case-sensitive so watch out 🙂

          xyz
          I knew it was something basic, Im to used to other game engines where the property starts with uppercase so whoops.
          Thanks again lol

          • xyz replied to this.

            Frodev It's not the engine thing but rather the GDScript naming convention thing. In Godot's C# bindings the same property names do start with uppercase.