Godot Version
4.3 stable
Question
I’m having a odd problem with a instanced object. It was working but now returned a error.
I have a data file that holds my workers (npc) and loads them when the game starts so that i can save the prexisting character data. It looks like this right now.
{
"worker_01": {
"id" : "worker_01",
"name": "Sally",
"worker_level": 1,
"attributes": {
"base_attack": 3,
"fear_resist" : 2,
"work_efficency": 3,
"defence": 2,
"walk_speed_boost": 5
},
"position_name": "WorkerSpawnLocation",
"status": "idle",
"machine_assigned": "Machine1",
"inventory": {},
"carrying": {}
}
}
When the game loads it does this to create the characters.
for nkey in PlayerData.worker_settings.keys():
var worker_instance = WORKER_NPC.instantiate()
worker_instance.worker_id = nkey
add_child(worker_instance)
The var worker id is defined in the instance code.
var worker_id
Now i’m getting a error when trying to assign the worker id to the instance.
Invalid assignment of property or key ‘worker_id’ with value of type ‘String’ on a base object of type ‘CharacterBody2D’.
I’m a little confused on why this is happening, perhaps someone can see the error that i don’t see?
Thanks