i cant assign 'weapons' in Node3D in Array?
the code works fine for everything else

@export var weapon1: Node3D
@export var weapons : Array[Node3D]
@export var weaponIcons : Array[CompressedTexture2D]
  • Shouldn't that array hold NodePath instead? Maybe I misunderstand it's purpose...

Shouldn't that array hold NodePath instead? Maybe I misunderstand it's purpose...

  • DJM replied to this.

    Megalomaniak
    cant seem to call a func on the nodepath

    	for slot in weaponIcons.size():
    		var weaponslot = TextureRect.new()
    		weaponInventory.add_child(weaponslot)
    	for icon in weaponInventory.get_children():
    		var iconindex = icon.get_index()
    		icon.set_texture(weaponIcons[iconindex])
    		icon.modulate = normalColor
    	
    	weaponIndex = currentWeapon
    	weaponIcon.set_texture(weaponIcons[currentWeapon])
    	weapons[currentWeapon].start()
    	weaponInventory.visible = false
    	inventoryOpen = false

    weapons[currentWeapon].start() > cannot find property in nodepath error

    Remember it's a NodePath not a node itself now. So you have to use get_node() and give it that NodePath.

    • DJM replied to this.

      Megalomaniak
      im confused, the new syntax in godot4 lets u declare nodes as export now, not nodepaths.
      how come i cannot assign an Array node3D but i can assign a single Node3D?
      for example
      @export var camera: Node

      That's not the issue, you are storing an array as the export variable.

      So the question is how do you store an actual node in an array? Either you store a NodePath that acts as the address to the nodes location so you can use get_node() to get it with. Or you store a reference to the Node, not an actual node itself, in the array.