Invidelis
(Invidelis)
1
Hello,
I’ve tried to spawn a static camera on begin play, i tested it in blueprints and wanted to translater it into c++
I’m pretty lost on how to achieve the same result.
`{
Super::BeginPlay();
FTransform transform(FVector(0.0f, 0.0f, 1000.0f));
FRotator Rotation = FRotator(0,-40,0);
UWorld* poWorld = GetWorld();
CameraActor = poWorld->SpawnActor<ACameraActor>();
CameraActor->SetActorTransform(transform);
CameraActor->SetActorRotation(Rotation);
}
`
Unsure if this is even remotely close to what I want, also missing the " SetViewTargetWithBlend "
Hello! Try it like this
You must add these includes in the file you are working on
#include “Kismet/GameplayStatics.h”
#include “Camera/CameraActor.h”
::BeginPlay()
{
FTransform transform(FRotator{.0f, -40.0f, .0f}, FVector{.0f, .0f, 400.0f}, FVector{1.0f, 1.0f, 1.0f});
UWorld* poWorld = GetWorld();
ACameraActor* MyCameraActor = poWorld->SpawnActor<ACameraActor>();
MyCameraActor->SetActorTransform(transform);
APlayerController* MyPlayerController = UGameplayStatics::GetPlayerController(this, 0);
MyPlayerController->SetViewTargetWithBlend(MyCameraActor, 2.f);
}
2 Likes