Switch on Class

I am curious if it would be worth it for Epic to create a “Switch on Class” node, for example

just like this switch node for enum, but having a class or soft class reference for input?

I am finding many situations where I wish I could create a switch on class, where, I can input a base class, and the out pins will be all the derived classes of the base class?

Is this not extremely useful? Am I missing a better way to be programming things instead of by using class? Right now, I am setting up sequence node and checking for each class in sequence and as soon as result matches, returns function result

So, this made me try something and it worked:
I had to use a string switch, and manually et each pin to the correct soft reference (I tried to copy Reference from Editor, but it adds extra and leaves out the “_C” at the end, so had to manually type in)


I also simplified by usig class display name

i think it would be better to just call an interface function and let the class handle its own logic

if the object doesnt exist yet you can wrap the class in a Struct/Data Asset or Data Table and add a GameplayTag for the switch

these would be more modular for future class additions

1 Like