I used to use meta data, or special flags, but lately I've been using another idea that I am favoring since it is more in line with Godot's internals.
I override the get_type()
and is_type(type)
methods in my classes.
It might look like this: (Though I generally use constants.)
func is_type(type): return type == "MyObject" or .is_type(type)
func get_type(): return "MyObject"
In the is_type(type)
it will also fall back to an inherited type. If your object extends a KinematicBody2D, you could still check for that with is_type("KinematicBody2D")
. The first condition == "MyObject"
would be false, then it would pass the parameter back to the original method for comparison, and if it matches will return true.