Nonexistant func in base nil, resource

Godot Version

4.4

Question

How do I get pathing:

extends Resource
class_name TurnQueueComponant

var turn_queue: TurnQueue

func set_queue(queue: TurnQueue) -> void:
	turn_queue = queue
extends Node2D
class_name Character

@export var turn_queue_companant : TurnQueueComponant = null
extends Node2D
class_name TurnQueue

func add_character(character: Character) -> void:
	turn_queue.append(character)
	character.turn_queue_companant.set_queue(self)   #<-This is saying its a nonexistent func in base `NIL` 

Character is a child of the TurnQueue

and TurnQueueComponant set inside Character @export

Did you assign it in the editor?

	character.turn_queue_companant.set_queue(self)   #<-This is saying its a nonexistent func in base `NIL`

i have yes! and made sure i saved it

Character is a child of the TurnQueue
and TurnQueueComponant set inside Character @export

Is the script you posted here correct? I’m getting a different error (Godot V4.4.1)

it is correct. thats apart of a different func. You should be able to remove that

extends Node2D
class_name TurnQueue


var active_character: Character
var turn_queue : Array[Character]
var turn_index : int = 0


func initialize() -> void:
	add_initial_characters()

	if turn_queue.size() > 0:
		active_character = turn_queue[0]

func _ready() -> void:
	initialize()

func add_character(character: Character) -> void:
	turn_queue.append(character)
	character.turn_queue_companant.set_queue(self)
	print(character.name, " has joined, total:", turn_queue.size())

func get_all_characters() -> Array:
	return turn_queue.duplicate()

func add_initial_characters() -> void:
	for child in get_children():
		if child is Character:
			add_character(child)

func next_turn() -> void:
	if turn_queue.size() == 0:
		return
	
	turn_index = (turn_index + 1) % turn_queue.size()
	active_character = turn_queue[turn_index]
	print(active_character.name, "'s turn
	")
	active_character.start_turn()

func _on_turn_ended() -> void:
	next_turn()

is full script

I couldn’t reproduce it.
You may have to intercept it, if it’s NULL (Empty) then create it yourself, depends on what you want to do.

	if not character.turn_queue_companant:
		character.turn_queue_companant = TurnQueueComponant.new()
screenshots

Thank you, btw! ended up getting it figured out

1 Like