- Edited
Hello everyone! In Godot 4 Beta, I had this piece of code:
func get_random_item_instance_by_type(type):
var items_of_type = items.values().filter(
func(v: Item):
return v is type
)
var rand_idx = randi() % items_of_type.size()
return create_instance(items_of_type[rand_idx])
And it was called like this:
get_random_item_instance_by_type(MeleeWeapon)
where MeleeWeapon is a class_name
But now that I've updated to 4.0.3, it breaks on "v is type" part, saying that "type" is now a known type. How can I achieve the same result of dynamically checking a type? I already tried with typeof and is_class() but none of them worked.