Hello Unreal Community,
I’m new to C++ programming any advice or examples of my question would be very much appreciated. I have 2 classes, Class A extend GameMode and Class B extend BlurprintFunctionLibrary both created in C++. I’ve created a function in Class B and in trying to call that function from Class A; Is this possible?
Hey thanks for the reply but I forgot to mention that the classes were both created in c++ and not blueprint…So maybe if you can also show me an example with the c++ class that would be great…
Just an extra note here - if you’re using a pointer to an Unreal class (as most of your code would probably be) you must also decorate the pointer declaration with UPROPERTY(), e.g.
UPROPERTY()
AClass2* CurrentClass2;
Otherwise you will run into trouble with the Garbage Collection - it will destroy these objects unless you’ve marked them as properties.
If you want to call the function from Class 1 in Class 2, you need to do it the other way round.
You want to include the header file of the Class 1 in Class 2 and create a SubObject there. Otherwise you can only call functions of Class 2 in Class 1.
Sorry, I’ve been looking through all of the posts and yet i still can’t find the command used to call a function from other classes, you say how to set it up, but not the actual command used to call the function