Is _ready and _process never meant to run in scene instances?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By L_Tenshi


I have a base scene with 3d spatial node, the node has a mesh that represents the sea and a separate sub-scene which holds my boat.

Test Scene (Main scene) tree
----(instance spatial)boat

Boat scene tree
–(spatial)boat <–Holds the script

The script is very simple

extends Spatial

func _ready():
	pass # Replace with function body.
func _process(delta):

The _init function works fine, but the _ready and _process do not. I feel like I should be able to run those two functions, am I missing a piece of the puzzle?

How do you instanced the boat.tscn in the main scene?

nightrobin | 2020-09-08 23:15

Drag and dropped into the scene tree.

L_Tenshi | 2020-09-08 23:21

How did you attached the script in the boat?
Inside the boat’s scene or via the boat subscene while in the main scene?

If I recall correctly, the boat scene script will override the instanced boat scene in the main scene.
So if the boat scene has no script, it will override the instanced boat scene with no script as well.

nightrobin | 2020-09-08 23:48

_init() is also defined in the same simple script you list above?

This should work…

Tim Martin | 2020-09-08 23:49

The script is attached in the boat scene (for easier templating). No overriding script was created on the testscene.

L_Tenshi | 2020-09-09 00:14

At initialization, yes it solves the problem. But what about running per-frame updates? Still no go.

L_Tenshi | 2020-09-09 00:15

I tried it, the _ready and _process works
Let me know after you downloaded it, so that I can delete it in my drive.

Sample Project

nightrobin | 2020-09-09 01:49

Got it. How odd, literally the same setup look

L_Tenshi | 2020-09-09 11:16

:bust_in_silhouette: Reply From: Tim Martin

Hi L_Tenshi,

Thanks for sharing the project, needed in this case.

The problem is that your instance of U96 in testscene has overridden the script parameter to be empty.

Click this circle-arrow button to remove the override and it works.

Script override

You sir are amazing. I’ve got to admit, I should have seen that coming from unity. Godot so far seems amazing, but I guess there are some quirks I’ve got to learn.

Thanks for the help, I was scratching my head all day yesterday!

L_Tenshi | 2020-09-09 13:19

:bust_in_silhouette: Reply From: st_phan

I had a different problem, but it fits the same question so I am posting it here for others to find:

Issue: _process didn’t seem to be executed
Solution: Node must be part of the scene tree

Option 1 (scene-file with a script attached):

onready var Spring = preload("res://camera/Spring.tscn")
onready var spring1:Node = Spring.instance()

func _ready():
	# Without add_child the spring1's _process function is never executed

Option 2
You can also the scene into the scene-tree using the Godot interface. Basically the same as option 1.

What DIDN’T work for me was using a class without a scene file:

onready var Spring = preload("res://camera/")
onready var spring1:Node =

func _ready():