[C++] Is object in specific class?

Hello!

I tried to check, if some object belongs to specific class. My code:

if (object->GetClass()->IsInA(APointOfView_System::StaticClass()))

This is part of a blueprint function, which looks like this:


(Get Object Type)

There was no errors during compilation, but when I launched my game, all i’ve got was instant crash.

Is there something, that i’m doing wrong?

Thanks in advance, Cookie.

You aren’t checking object for null. Change your code to the following

if (object != nullptr && object->GetClass()->IsA(APointOfView_System::StaticClass()))

Yes, that was my problem. :slight_smile: I solved it by making a branch with condition pin connected to “Return value” output from LineTraceByChannel. But this solution is much more elegant, thanks!