TLDR: You can’t reference objects like this. The issue is that you are editing the gamemode actor class, not an instance of the gamemode actor (it hasn’t been spawned yet, since the game isn’t running). You are trying to reference an actor from a level, but the engine can’t tell what’s in the level until you actually spawn the object (the gamemode in this case). After spawning however, it will be able to say: “hey I see this camera actor, I’m gonna use it as my CameraActorView”.
If you give us a bit more context on what you are trying to do with this, I can be more specific, but for now, here’s some code that returns the first camera actor it finds. You can call this in BeginPlay() for example.
// .h
ACameraActor* FindFirstCamera();
// .cpp
ACameraActor* ALearnGameMode::FindFirstCamera()
{
for (TObjectIterator<ACameraActor> It; It; ++It)
{
ACameraActor* CameraActor = *It;
if (CameraActor)
{
// Found a camera actor!
return CameraActor;
}
}
UE_LOG(LogTemp, Error, TEXT("No camera actor found in the level."));
return nullptr;
}
// set your variable in BeginPlay() for example
cameraActorView = GetFirstCamera();
So i have to iterate all over instances of class type (“Camera”) to get the camera instance i want ?, isn’t that a bad prespective ? in large levels where you have a lot of camera instances ?