I have the following code in my DomeCameraPawn class:
void ADomeCameraPawn::MoveCameraUp() {
FVector Location = GetActorLocation();
FVector VectorUp = FVector(0, 0, MovementIncrement);
Location += VectorUp;
SetActorLocation(Location);
}
void ADomeCameraPawn::MoveCameraDown() {
FVector Location = GetActorLocation();
FVector VectorDown = FVector(0, 0, -MovementIncrement);
Location += VectorDown;
SetActorLocation(Location);
}
Initially in the blueprint, I’ve set these to respond to keyboard press events:
But, I want my code to be almost purely in C++.
So I was thinking of taking the user input (keyboard presses) in the code itself and then connecting them to the MoveCameraUp and MoveCameraDown functions using a simple if/else.
However, I can’t seem to find how to take in user inputs. I was told to use PlayerController
or GetFirstPlayerController() but I’m lost at how. Here is one attempt that failed:
if (UWorld* World = GetWorld())
{
FInputKeyManager* input = World->GetFirstPlayerController()->PlayerInput();
}
TIA for any help or guide!