Hey all I am rather a beginner but trying to get better at coding in C++ for UE4. I am trying to access a Blueprints properties that are derived from a C++ class. So for example I have:
int SomeNumber;
in the first class and then made a Blueprint based off this class. Then in my second class I have a reference to the Blueprint using:
UPROPERTY(EditAnywhere, Category = "OtherObject")
TSubclassOf<AOtherObject> OtherObjectBP;
I have been able to spawn instances of this OtherObjectBP but in my .CPP file of this class I would like to access the variables of OtherObjectBP and can’t seem to figure out. I had assumed it would just be
OtherObjectBP->SomeNumber;
but that doesn’t work. Also if I am completely thinking about this the wrong way please point it out I have been working on code for a bit now so I may just be missing the obvious. Thanks in advance.
After some fiddling I was able to access the variable I want but only after creation. So I’m now trying to find a way to do it without having to spawn the object before hand.
if (OtherObjectBP)
{
UWorld* const World = ();
if (World)
{
AThisObjectClass* SO = World->SpawnActor<AOtherObject>(OtherObjectBP, FVector(-390.0f, 280.0f, 180.0f), FRotator(0.0f, 0.0f, 0.0f));
int32 test = SO->SomeNumber;
UE_LOG(LogTemp, Warning, TEXT("Catch Rate: %d"), test);
}
}