Hello guys,
As you might have guessed I have Unity background. I created a c++ class derived from ACharacter and called it APlayerCharacter. After that I created a blueprint derived from APlayerCharacter. In PlayerCharacter I have a pointer UStaticMeshComponent* StaticMeshComponent. My PlayerCharacter::BeginPlay looks like this:
void APlayerCharacter::BeginPlay()
{
Super::BeginPlay();
this->StaticMeshComponent = nullptr; // Initialized in the constructor, placed it here for clarity.
this->StaticMeshComponent = this->FindComponentByClass<UStaticMeshComponent>();
if (StaticMeshComponent)
{
UE_LOG(LogTemp, Warning, TEXT("GOT IT!"));
}
}
At the moment I am experimenting. The whole setup doesn’t make so much sense, but in Unity there is a method called GetComponent() where T is a MonoBehaviour (Almost equivalent to Actor Component) attached to a GameObject (the equivalent to Actor). So Unity has a Attribute [RequireComponent(type of what we are looking for)] placed above a certain class. Is there something similar in Unreal?