You can’t do it specifically like you mentioned, but you can use a Variant type instead - in such a case, you can feed any class into that variable.
Or depending on the structure of your classes, you can make them inherit the same base abstract class and then use that abstract class in your variable declaration.
e.g. both StaticBody2D and CharacterBody2D inherit from PhysicsBody2D
and this will allow you to feed CharacterBody2D, RigidBody2D or StaticBody2D into that variable.
You can do the same with your class structure and use inheritance.
ok i understand this. But is there a way i can mimic such kind of behaviour without mentioning thier common ancester. because if we mention them then still godot have to find the type of class at run time to find it’s data. making it static was whole point is too avoid runtime load.
What you think about this?
Thanks for repley.
If performance is your concern - then I would advise you to not worry about it, unless you encounter some specific bottle neck with this. There are way worse performance-sinks in the engine than this.