How to check if an actor is from a certain class?

Hi, the “Equal (Object)” function let us pass game actors as well as blueprints classes so they can be compared for flow control, however if used with a condition to see if an actor passed from an Overlaping event (Other) is from a certain blueprint class it apparently doesn’t work, it only works (as far as I know) when comparing two actors or two blueprint classes, but not an actor and a blueprint class.

So how canwe check if an blueprint actor’s class is equal to one blueprint class we set (like from a drop menu)?

1 Like

Hey Albert,

You should be able to use Get Class on your Object and then plug that into a Class is Child of node:

8 Likes

Thanks for the response, “Class Is Child Of” is a very useful function. I’ve put it into practise and it works as expected.

In code it looks like this:
if(Object->GetClass()->IsChildOf(YourClass::StaticClass())) {}

6 Likes

Or alternatively:

if(Object->IsA(YourClass::StaticClass())) {}
8 Likes

Sorry to revamp this thread as answer was very helpful for me, but I am trying to understand why the Equal(class) node didnt worked for me. It should be the same if I set in some other blueprint parentclass as the one tested no?

It working well - class way

I don’t know why tag not working. I can check tags on hit from bullet side, but I can’t check tags on hit body (tags from bullet). Projectiles.

What if YourClass is a blueprint class?

In class flags which you can get from UClass you can check CLASS_Native flag to see if class is native (in dll aka in C++)

You can also use the node Is A
image

1 Like