Question about how to handle collisions with different actors

Can anyone point me in the right direction? I have a ‘wall’ in a game with a box collision that I want to take different actions based on what hits the wall. If the other actor is an enemy I want one thing to happen, if the actor is an ally I want something else to happen. Is there any kind of a ‘switch’ or ‘case’ that I can use based on the class that collides? Or do I have to do something like the screenshot below where I cast to one thing, then if that fails, cast to the next, and so on until I get the actor / behavior that I want?

Thank you for taking the time to read this.


You need to cast to an instance of the class, not the class in general:


And, yes, you just need a chain of ‘casts’… A macro is about as neat as you can get:


1 Like