Code body where error occurs.
if body.get_parent_node_3d().get_parent() is Monster:
print_debug("A monster is in range!")
print_debug(body.get_parent_node_3d().get_parent().name)
var monster_in_range = body.get_parent_node_3d().get_parent() as Monster
if monster_in_range.owning_player == current_monster.owning_player: # ERROR HERE
print_debug("This Monster in range is an ally, do not target.")
return false
else:
print_debug("This Monster is a foe! Target them.")
return true
elif body.get_parent_node_3d().get_parent() is Vaite:
print_debug("Vaite is in range!")
print_debug(body.get_parent_node_3d().get_parent().name)
var vaite_in_range = body.get_parent_node_3d().get_parent() as Vaite
if vaite_in_range.player_name == current_monster.owning_player:
print_debug("This Vaite is an ally, do not target.")
return false
else:
print_debug("This Vaite is a foe! Target them.")
return true
else:
print_debug("Something is in range but not a possible target.")
print_debug(body.get_parent_node_3d().name)
return false```
Where "owning_player" is declared in the base class's script for Monster.
```@export var owning_player: String = "Natural" # "Natural" if not a summoned monster.```
Error: `Invalid access to property or key 'owning_player' on a base object of type 'Nil'.`
Judging from the 'Nil' in the error message I assume me trying to set `monster_in_range` is failing. I'm brand new to Godot so not sure if I'm doing it wrong. I'm trying to store the reference to the Monster that gets within target range then compare its ownership String value to see if it should target them as an enemy.