I have two Camera Components, first one Inherited from C++ base class (ThirdPersonCamera), the other added via blueprints (FirstPersonCamera), this getting parented to my Character mesh on a socket.
When using FindComponentByClass()
it’s only returning the “ThirdPersonCamera”. I thought using an array would solve this, but it just returns multiple “ThirdPersonCamera”
So how can I get a reference to my FirstPersonCamera in C++? I need it for starting a line trace from my “FirstPersonCamera”.
This being the array I used.
UCameraComponent* Camera;
TArray<UCameraComponent*> CameraArray;
for (int32 i = 0; i < 2; i++)
{
Camera = FindComponentByClass<UCameraComponent>();
CameraArray.Add(Camera);
}
for (int32 A = 0; A < CameraArray.Num(); A++)
{
UE_LOG(LogTemp, Warning, TEXT("Name: %s"), *CameraArray[A]->GetName());
}