How to implement native Engine interface in custom C++ class?


I am trying to implement RVOAvoidance interface in my custom C++ movement component which inherits from FloatingPawnMovement component. There’s pretty much no documentation for it, but the interface said to use CharacterMovementComponent implementation as a reference, so I started to scramble all the avoidance stuff from the CharacterMovementComponent and transfer it to my class. I just tried to do the header first and see if it compiles, but I am having no luck.

Apparently, IRVOAvoidanceInterface requires ENGINE_API, but my custom C++ class is my project’s API. I can’t replace MYPROJECT_API with ENGINE_API as it won’t compile, and I also can not put two different API macros inside the class declaration. If I don’t add ENGINE_API, then I get many unresolved symbol errors. If I do add ENGINE_API, the errors disappear but the class declaration formatting is not valid.

This is what I am starting with:

class FIRSTWAR_API URTSUnitMovement : public UFloatingPawnMovement, public IRVOAvoidanceInterface

So my question is how do I implement native Interface which requires ENGINE_API into my custom C++ class. Does it require adding some module or something?

You have to include the module name into your public dependencies list inside of your Build.cs file.

You can search and see a header’s module on API pages:

Well, according to that page the module is “Engine” which is already included by default. I really don’t know what I am doing wrong as I seem to be doing exactly the same things WheeledVehicleMovementComponent and CharacterMovementComponent do.

This is what I get:

This is what I get when I replace my project’s API macro with ENGINE_APIThis is what I get when I try to use both macros, like:

class FIRSTWAR_API URTSUnitMovement : public UFloatingPawnMovement, ENGINE_API public IRVOAvoidanceInterface

Or like:

class FIRSTWAR_API URTSUnitMovement : public UFloatingPawnMovement, public ENGINE_API IRVOAvoidanceInterface

I know I am probably doing something really stupid but these things are really hard to figure out for beginners.

Also WheeledVehicleMovementComponent is actually a non native module, so that one doesn’t even contain any ENGINE_API macro in the header and still works.

Okay, solved. I am an idiot, as usually.

I’ve just added header declarations, and had completely empty .cpp file. I just wanted to see if a header compiles first, as without experience, I assumed that the compiler will simply skip declarations that don’t have any definitions in .cpp (general assumption that green squiggly lines mean “not a big deal”), but I had no idea that if you implement interface, compiler won’t skip missing definitions. :slight_smile:

It will skip if you set “void memberFunction() = 0;”
Can’t do that for UFunction tho