x

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"

Comparing class variable to object variable's class

So for example, in one place I have a TSubclassOf variable. Then I have a UThing* variable elsewhere that the previous variable is used to spawn. I'm trying to perform a check to see if the UThing* is an instance of the same subclass of UThing that I have stored in the TSubclassOf variable. I'm a bit stumped on how though - my first thought had been to compare the TSubclassOf variable to the return value of GetClass() called on UThing*, but that didn't work. I have a controlled scenario where I know the can't be any other subclasses spawned (because right now there's only one and I can see instances of it in the details panel), but it's still returning false. I'm not sure where to look for other solutions, either. I've looked at reference documentation for TSubclassOf, but I didn't see anything that immediately jumped out at me as a way to solve the problem.

Product Version: UE 4.9
Tags:
more ▼

asked Sep 13 '15 at 08:26 PM in C++ Programming

avatar image

Cancermantis
6 1 2 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Try IsA(Class), it's function in actor so you need to use it this way:

SomeObject->IsA(UThing::StaticClass());

Is a returns true if actor is related to class you inputed, you use GetClass() comparison if you want to check if object is exactly that class you searching for, that the difference between those 2 methods.

Also TSubclassOf is template for UClass* which limit selection to specific class relation, if you use UClass* insted of TSubclassOf it will show you all UObjects classes. TSubclassOf got operator override to UClass* it's work the same. So if you look for refrence you should look here:

https://docs.unrealengine.com/latest/INT/API/Runtime/CoreUObject/UObject/UClass/index.html

more ▼

answered Sep 14 '15 at 12:21 AM

avatar image

Shadowriver
36.6k 932 169 1111

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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