Calling built in functions in a preloaded script

Godot Version

4.2

Question

Hi,
I’m new to Godot and I’m trying to build a simple game. I have a script that describes the overall behaviour of a building, which preloads a more specific script.
The relevant fragments are:

var production_script
const PS: Script = preload("res://Scripts/BuildingProduction.gd")

func _ready():
	production_script = PS.new()

Now this is all and dandy, but my issue lies here:
The _process function is never called in the preloaded script, I have to resort to manual call of the function:

func _process(delta):
	production_script._process(delta)

Am I missing something, is there some more elegant way to do this?

_process is called by the engine only on nodes within the scene tree - you will need to call it yourself if it’s not a node added as a child.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.