`_physics_process` not called in [non-Node] custom class

Godot Version

4.2.1

Question

I’ve developed a custom class that listens to OSC messages in its _physics_process() method. That class is not a Node, but I added it as a child of the Main node with:

extends Node2D
class_name Main

var osc: OscReceiver
...
func _ready():
    ...
	osc = OscReceiver.new()
	self.add_child.call_deferred(osc)
    ...

It used to work but, at some point (not sure when), it stopped receiveing messages, unless I call OscReciever’s _physics_process() explicitly from Main’s _physics_process() or I convert OscReceiver to a Node.

Has the managing of _physics_process() changed?

I’ve seen this thread but it’s not exactly the same case. I need only one instance of my class.

That’s not possible, add_child expects a Node as its first argument. This should throw an error!

What you want is impossible, _physics_process is a Node callback, if you want that you script calls it automatictly you need to make a Node derivated class

https://docs.godotengine.org/en/stable/classes/class_node.html#description

2 Likes

Thanks @njamster , that’s what I figured, but somehow it doesn’t throw the error.

OK, I’ll make it a node, then. Thanks!