Godot Version
v4.2.2.stable.official [15073afe3]
Question
Hi! I’m just getting started with godot and being a game developer, so I follow this tutorial and not getting idea what’s wrong with it. Here the error:
Invalid set index 'mesh' (on base: 'Nil') with value of type 'ArrayMesh'.
and the code:
@tool
extends Node3D
@export var WEAPON_TYPE : Weapons:
set(value):
WEAPON_TYPE = value
#print(value)
load_weapon()
@onready var weapon_mesh : MeshInstance3D = %WeaponMesh
@onready var weapon_shadow : MeshInstance3D = %WeaponShadow
# Called when the node enters the scene tree for the first time.
func _ready():
#print(WEAPON_TYPE.mesh)
load_weapon()
func load_weapon():
weapon_mesh.mesh = WEAPON_TYPE.mesh
position = WEAPON_TYPE.position
rotation_degrees = WEAPON_TYPE.rotation
weapon_shadow.visible = WEAPON_TYPE.shadow
I notice something in the error details that the weapon_mesh and weapon_shadow is still set as null
This is inside the weapon:
and this is how I install the mesh:
Did I do something wrong in it? I really don’t know what is happening that causing that. Could anyone help me?
Thanks!