Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

Accessing Subclasses of a class in C++

Hello All,

I just had a quick question because I'm having a hard time finding documentation that I can really understand on this issue.

I'm trying to get the class of an actor and compare it to one of my custom classes (to determine whether the actor is an instance of my class of interest. The problem here is, the compiler complains about this (what I have below) and I don't really know the syntax for this or why it will or will not work. Additionally, I would actually like to make my statement check "if ActorClass == (AnySubclassOf)AMNPickup" but I'm having a bit of a hard time figuring out how to do this. I'd really appreciate any help here. Even links to documentation that I may have overlooked would be helpful.


 void AMNCharacter::CheckForInteractables(){
     TArray<AActor*> ThingsImTouching;
     for (AActor* Thing : ThingsImTouching)
         if (Thing->GetActorClass() == AMNPickup)

EDIT: Just a note, VS is telling me that I can't use AMNPickup because: "type name is not allowed"

Product Version: Not Selected
more ▼

asked Oct 14 '14 at 11:06 PM in C++ Programming

avatar image

120 14 20 22

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

try AMNPickup::StaticClass().

All UObject derrived classes have a StaticClass() which returns their UClass*. Any UObject can also tell you if it is a subclass of another UObject type: Thing->IsA(AActor::StaticClass()) would == true for example.

more ▼

answered Oct 14 '14 at 11:25 PM

avatar image

326 11 14 225

avatar image The7thCrest Oct 14 '14 at 11:28 PM

Wow... I tried that earlier and it didn't work... I must have typed something wrong... thanks for pointing this out.

Also IsA() is going to be very helpful in the future. Thanks a bunch.

avatar image zoid Oct 14 '14 at 11:30 PM

My pleasure good luck!

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question