I'm trying to check if an object adheres to certain restrictions by checking its type against a given check_type variable. This variable is set dynamically, so I cannot check against a fixed class name.
var check_type = get_type_restriction()
if thing_to_check is check_type:
do_something()
I tried several things (Object type hint for check_type, Script type hint, no type hint) but get the error: check_type is a variable but does not contain a type, or: local variable check_type cannot be used as a type.
is_class("ClassName"). You cannot use a variable with is in GDScript, is only works with static type hints.class_name X). For this, it's best to useis_instance_of.