Hello everyone, firstly a little disclaimer : I am really new to UE. I’ve been working with Unity3D for a few years and I’ve worked in C++ in the past, but I’m just stumbling my way through UnrealEngine right now.
The Question :
I’m trying to get ROSIntegration to work inside my Carla Project. From what I understand Carla is a UE Project that depends on a plugin and ROSIntegration is itself a Plugin.
My problem after compiling the two is that they both have classes derived from UGameInstance and they both need it as the main GameInstance.
Now I was thinking I could just have one inherit the other (probably UROSIntegrationGameInstance derived from UCarlaGameInstance) since they don’t share any properties, functions or members (at first glance). Even that might be a really bad idea and I wouldn’t know …
But when I try to do that :
class ROSINTEGRATION_API UROSIntegrationGameInstance : public UCarlaGameInstance
The compiler cannot find the include file. I looked it up a bit, tried updating the Visual Code project, and visual studio finds it (no error squiggles) but not the compiler. I’ve also tried using an absolute path but then it can’t find another one and I feel like I’ll get running forever until all include path are absolute.
So do you guys have any pointers to help me find a solution ? Maybe you’ve even worked with those plug-ins. Anything to clarify my situation would be welcome right now. And if you have no idea how to help me thank you for reading anyway.
My Config :
- Ubuntu 18.04
- Unreal Engine 4.22 (built from source, stable branch)
- Visual Studio Code
- Carla - master branch
- ROSIntegration - master branch
Have you tried making one within your project that inherits form both?
I had forgotten multiple inheritance was a thing in C++.
So I’ve tried :
class CARLAUE4_API UMyGameInstance : public UCarlaGameInstance, public UROSIntegrationGameInstance
The good news is : the compiler finds the files. And I also understand better how to work in C++ in UE.
The bad news is : it complains that its not an interface (Can only inherit from non-UObjects or UInterface derived interfaces).
I think the problem is that we now have a Diamond inheritance of UGameInstance which inherits UObject, and I guess UObjects aren’t safe to “diamond-inherit” in some way
The reason for the compiler to not find the header might be because you did not add the module fo your game to the public dependencies of the plugin (or viceversa). Check your Build.cs file and add the module name on the public dependecy modules (the module name and your game/plugin name are the same).
For instance, this is an old project of mine, I’m using three plugins classes in it so I added them to my project .Build.cs file:
Hope this helps. Make it a great day!
Why can’t you do the opposite? Plugin should not be dependent on game project and Carla is game project right? So make UCarlaGameInstance to inherent from UROSIntegrationGameInstance, remember to add module dependency in *.build.cs, module name is directory name after Source directory, for excample:
Also UObjects don’t support multiple inference other then interface.
Carla(CarlaUE4) is a project that depends on a plugin(Carla) and UCarlaGameInstance is defined in the plugin. So both of the GameInstance derived classes are defined in plugins (which shouldn’t be dependant on each other either)
I finally got it to work as intended after finding this question for another problem later on.
Basically the solution was to add the module to the public dependencies like you guys said, but not to the build.cs of the project rather the one of the plugin itself. Which I didn’t know there was one. And also add a plugin to the .uplugin plugin section.
So I got that in Carla.uplugin :
I feel like I’m learning something new every hour or so now that I understand a bit better UE code architecture.
Thank you everyone for your help. I greatly appreciate it and will try to help the next one when I know more about how everything works.