Is it possible to create a custom Switch on, like switch on actor?

I been working in a game where i have multiple players with different actors, and they and i wanted to do something like this:


But instead of String i want it to be a Class or Actor and in this part

image
like select what happen if X actor is in the list?

i know barely nothing about scripting in cpp, if i had to do it ill do it, but i need to know if this is possible, thx

What you mean by multiple players with different actors? do you want to switch based on player ? or based on actor type? Can you explain your setup a bit more? u can use Game State - Player Array to get all players or Player Slot ID , is this multiplayer?

you can but it would require a custom k2node which is complicated BUT its a bad idea.

or you can create a macro which is just if class then exit repeated.

but the reason its a bad idea is its loading all the classes into memory. the better way is to just give your actors custom Tags/GameplayTags or Enums and return it on interface and can switch it just check HasTag

I mean i have a few players witch had derivate from the same pawn, but they all have different mesh and some different mechanics


And i already solved it with this setup:


, but im curious that if there is any possibility to do that with an actor or a class, that’s it

Its fine the solution you show me, i already solve it with:

Im still curious if there is any possibility because i encountered this issue multiple times and just thinking about this solution, but thank you!

looking at your code i think you just want an interface and then every class can handle its own logic, no switch required

i mean i could, and i could just overwrite the funcion and set separated the logic of the other pawns, but im kinda lazy and i want it in the parent, and as i said, im still curious about that possibility, thanks anyway

you can also just override it in the parent if they share inheritance, trust me its much easier and scalable than a giant switch statement

I know, but its not like a switch for everthing, its a switch for X Specific Actors

well you can only create one in c++ but as said you can wrap what you already have in a macro to reuse it