Hi everyone !
I am trying to make a system where every part of a level has its own camera. So, I have a ASubLevel class, inherited from AActor. There, I have a UCameraComponent :
/** Header */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
UCameraComponent* PlayerCamera;
In the contructor, I initalize the component :
PlayerCamera = PCIP.CreateDefaultSubobject<UCameraComponent>(this, TEXT("PlayerCamera"));
PlayerCamera->bConstrainAspectRatio = false;
PlayerCamera->AttachTo(RootComponent);
So, after in the constructor, if I want, I can access its properties. But then, in the tick function, it is impossible :
void ASubLevel::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
if (!PlayerCamera)
UE_LOG(LogTemp, Warning, TEXT("Can't access PlayerCamera !"));
}
This line is always executed in the log of the engine. So, the tick function is executed. But, when I try to access the properties like with
PlayerCamera->GetCameraView()
Then the engine crashes like if the pointer was NULL.
Than you for helping me !