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"

Non-uobjects limitations


So, I'm trying to assimilate into UE. Today I'd discovered, that I can't use dynamic_cast with classes, that don't derive from UObject. Later on I found out, that I can't use templates with UObjects.

My question is: what are the limitations for non-unreal classes and what are the limitations for unreal classes?

Thanks in advance

Product Version: Not Selected
more ▼

asked Jan 29 '15 at 03:34 PM in C++ Programming

avatar image

31 3 5 7

avatar image Shadowriver Jan 29 '15 at 03:51 PM

No, you should be able to do so, C++ in UE4 is normal C++ so it should let you do things outside UE4 conventions. Can you paste errors you getting?

avatar image vivalavladislav Jan 30 '15 at 12:06 PM

Consider following example:

 #include "King.h"
 #include "MyClass.h"
 class IState
     virtual bool Equals( IState* other ) =0;
 template< class TState >
 class State : public IState
     virtual bool Equals( IState* other )
         TState* casted = dynamic_cast< TState*>( other ); // problem here
         return Equals( casted );
     virtual bool Equals( TState* casted ) =0;
 class IntState : public State<IntState>
     virtual bool Equals( IntState* other )
         return other == this;
     IntState state;
     state.IState::Equals( &state );

The error I get is in Casts.h and i says cannot use dynamic_cast with -fno-rtti

avatar image janimationd Mar 12 '18 at 10:25 PM

Did you enable RTTI in your build script?

avatar image Shadowriver Jan 29 '15 at 03:53 PM

Also objects outside UObject are not managed by UE4 garbage collection as well reflection system (you can't intract with them via Blueprint)

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

1 answer: sort voted first


Limitations for non-unreal classes:

In general, there is no limitation for it. UE4 use visual studio 2013 compiler. Therefore, if you class compiles in non-UE4 project, it would be compile in UE4 project. By default, run time type identification is disabled in UE4. If you really need it, just add next string to your project module rules (*.Build.cs).

 bUseRTTI = true;

In addition to Shadowriver about uobjects:

You cannot create class derived from two “unreal classes”. Can only inherit from non-UObjects or UInterface derived interfaces.

 class AMyCharacter : public ACharacter, public AActor // error
 class AMyCharacter : public ACharacter, public NonUObjectClass, public IInterfaceClass // ok

Best regards, Gleb

more ▼

answered Jan 30 '15 at 01:35 PM

avatar image

1.8k 76 19 143

avatar image vivalavladislav Feb 02 '15 at 02:25 PM

Hey, Gleb.

What about mac, same solution? I've added truth assignment, but it doesn't seem to work. The xcode.proj settings' 'enable RTTI' also checked.

(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