Is it possible to make pointer to a class without specifying class name?

I’m trying to create a trace to an object and check if it’s a certain type of object via a variable. But the problem I see occurring is things going haywire if I define a class type to select, and then when tracing to an object with an invalid class type, it’s going to glitch out really badly or even may be even crash. Probably not, but I’d rather be cautious.

Is there any way I can create a pointer to a class/object without defining the class type in the pointer? I’m having to define AActor* or UClass* which I don’t really want to and doesn’t exactly work for me. Specifying the type of the object I want to select however, again, could cause issues in the code.

On top of that, I need to be able to check if the class/object I’m selecting has a property and if that property has a certain value. Checking for value doesn’t seem to be possible as VS instantly errors things out for me saying that AActor or UClass doesn’t have the specified property type, so is what I’m trying to achieve even possible to do? Or is the error type of “pointer to incomplete class type not allowed” indicate exactly the fact that this is not possible? In which case, how could I handle this?

I found IsA() function, which could work for checking class type, but it doesn’t seem to like to take a variable as a value and the documentation for this function doesn’t tell me anything at all.

If you need more info on this, do let me know and I’ll try to provide it.

This is exactly the type of thing interfaces are great for. You can define an unreal interface and have these various objects implement it, then have your function accept a pointer to the interface type.

Alternatively, you could accept type AActor (or UObject if parameter might not be a type of actor), then use casting to the expected types within the function to see what type you are dealing with, and use reflection to check for and get the property you are looking for.

An interface would be much cleaner and simpler though.

Casting seems to work, but, at the same time, it’s not really allowing me to do much, since I can’t even do something like this (class type to be cast to can’t be a variable’s value, at least not an FName type one):

Cast<[name of class as a variable]>([class pointer variable]);

Would you be able to show me an example of how interface could be used for this? I’m having hard time understanding how this could be useful, or what interfaces are supposed to do exactly.