order of operation differ between package and PIE
When a camera is setup in code with
GetWorld()->GetFirstPlayerController()->SetViewTarget(this);
the camera will work in the editor but a packaged version of the game has a black screen.
1. Open UE4 Editor (any project)
2. Create BP based on Game Mode (NewGame)
3. In World Settings, set game mode to NewGame
4. Set Default pawn to None
5. Add code to project based on actor (NewActor)
6. In constructor, add the following:
bFindCameraComponentWhenViewTarget = true; PrimaryActorTick.bCanEverTick = true; AutoReceiveInput = EAutoReceiveInput::Player0;
7. In Tick() function, add the following:
GetWorld()->GetFirstPlayerController()->SetViewTarget(this);
8. Compile and reopen project in the editor
9. Create BP based on NewActor
10. Add camera component to BP
11. Add instance of BP to the level then PIE
12. Create packaged version for Win64
13. After Packaging run .exe
Result:
View from step 11 will be of the BP camera while step 13 only shows a black screen.
Head over to the existing Questions & Answers thread and let us know what's up.
0 |
Component | UE - Gameplay |
---|---|
Affects Versions | 4.6.1 |
Created | Feb 19, 2015 |
---|---|
Resolved | Sep 2, 2015 |
Updated | Jul 14, 2021 |