My First Blueprints to C++/CPP

I’m sorry that this is such a simple question. I’ve been watching videos on conversion the past few days but something just isn’t clicking.

All the ufunctions have been created in the header, so I’m just trying to figure out the format of the CPP, I know it’s all wrong. I’m trying to get the info from my Blueprint Interface, but:

My AC_AttributesManager.CPP

void UAC_AttributesManager::Initialize()
{
CreateAttributes();
GiveStartAbilities();
(IBI_InteractionInterface::GetStartingData);
ApplyTags(GameplayTags);
}

Here’s what I’m trying to turn into code.

Sorry again, it’s my first blueprint conversion, I’ve got my header game down, but this is still a mystery.
I can understand other peoples code and find similar use cases but just need a little push. Thanks for taking a look and sorry again it’s such a noob question.

That’s just an example… if you do it like this it won’t work

header file

AC_AttributesManager.h


UCLASS()
class CPPPROJECT_API UAC_AttributesManager : public UObject
{
GENERATED_BODY()
public:
UFUNCTION(Blueprintcallable)
void Initialize();
void CreateAttributes();
void GiveStartAbilities();
void ApplyTags(…);
};

(Implementation) CPP File

AC_AttributesManager.CPP

void AC_AttributesManager::Initialize()
{
//Some code
}
void AC_AttributesManager::CreateAttributes()
{
//Some code
}
void AC_AttributesManager::GiveStartAbilities()
{
//Some code
}
void AC_AttributesManager::ApplyTags(…)
{
//Some code
}


What I mean by this is that if you don’t know C++ you should take a course first before starting with Unreal…
It is not a good idea to start a house from the roof.
otherwise all this for you will be the same as Mandarin Chinese.

Well, thank you. I understand Blueprints pretty thoroughly. So the concept of C++ makes broader sense, like I know the words in Mandarin, but not the most literal punctuation, I’m just having trouble taking that first step to “connect some nodes” in C++

I very well might be wrong but from what I understand, what you provided is how to create the functions individually.
But how do I define Initialize by combining those other functions.
I assume just ordering them is like connecting the nodes?
(Assuming all the functions have been defined)
Would “Initialized” look like:

CPP

void UACAttributesManager::Initialize()
{
ACAttributesManager::CreateAttributes();,
ACAttributesManager::GiveStartAbilities();,
(IBI_Interaction_Manager::GetStartingData)();,
	AActor* GetOwner() const
Void UACAttributesManager::ApplyGameplayTags()
}

I can’t call the Blueprint Interface (BI_InteractionManager) like that can I? Is it possible not to specify the values of each pin?

An interface in C++ is an abstract class.
The functions are called the same as the others.
It’s more or less like this…

void UACAttributesManager::Initialize()
{
CreateAttributes(Pin1, Pin2, Pin3);
GiveStartAbilities(Pin1, Pin2, Pin3);

GetStartingData(Pin1, Pin2, Pin3);//<-- Interface

GetOwner(Pin1, Pin2, Pin3);
ApplyGameplayTags(Pin1, Pin2, Pin3);
}

Trust me, take a little C++ course. There are many videos on YouTube. In a month you will have a general idea of how all this works.

If you know blueprints everything will be much easier for you.
But believe me you still have a lot to learn.
But don’t worry because it’s very easy.
Unfortunately it is not something that is learned in 5 minutes.
I’ve been learning for 20 years and I still don’t know a lot of things.

But with a mini C++ course with the basics you have enough to get started.

You can do it!! :slight_smile:

First of all you are not supposed to call things that only exist in Blueprint from c++.

If your goal is just to make your own Blueprint functions in c++ and try to call them in c++ that is a good starting point but it quickly becomes complicated when you don’t even know the basics of c++.

You need to provide more context if you need actual help writing the blueprint in c++ but you obviously won’t learn c++ just seeing the solution.

1 Like

If you want interfaces in c++

// Where Execute_MyFunction means MyFunction will be called on the interface's actor 
	if (MyClass->ImplementsInterface(UMyInterface::StaticClass())) {
IMyInterface::Execute_MyFunction(ActorThatImplementsSaidInterface,passedParameterToInterfaceFunction); 
}
			}
1 Like

Thank you so much Raven, I was not understanding that the ActorThatImplementSaidInterface could not be left as just a text of the tags and was wondering why it wasn’t connecting! TY!<3

Yes because the interface is called in a sort of reverse order it’s left side is the interface and so it needs to know who is the interface being called on.
Depending on the called function you need to pass in the same parameter types as the predicted function.

Delegate binding functions work in a similar way (but you do not need to pass in variables but the matched function has to have them)

1 Like

Thanks again Raven, you got me a long ways. Here’s the code that built fully for me.
After a bit of research it appears “Execute_” might have been depreciated.
Thank you all for the hints!


UACAttributesManager::UACAttributesManager()
{

}

void UACAttributesManager::Initialize()
{
	CreateAttributes();
	GiveStartAbilities();
	if (IBI_Interface* Interaction = Cast<IBI_Interface>(GetOwner()))
	{
		Interaction->GetStartingData(AppliedGameplayTags, SetAttributeObject, Designation, MaxLevel, DataTable);
	}
	else
		return;
	ApplyGameplayTags(Tags);
}