Hi!
I recently finished the Simple Shooter course and wanted to extend on it a little bit. I basically want a zoom on RightMouse click.
I’ve made this in about a minute in BP and it works exactly the way I want it too. However, I’d like to replicate this in C++ since every thing else is there as well and I figured this would be simple enough for me to learn how to do this in C++ (spoiler, I was wrong).
I made two bind actions:
PlayerInputComponent->BindAction(TEXT(“Zoom”), EInputEvent::IE_Pressed, this, &AShooterCharacter::ZoomIn); | |
---|---|
PlayerInputComponent->BindAction(TEXT(“Zoom”), EInputEvent::IE_Released, this, &AShooterCharacter::ZoomOut); |
I then made two functions, ZoomIn, and ZoomOut:
(The debug log was there to test the IE_Released, all working as expected).
void AShooterCharacter::ZoomIn()
{
// On Pressed. SetFieldOfView() to 90;
UE_LOG(LogTemp, Warning, TEXT("Zoom in"));
}
void AShooterCharacter::ZoomOut()
{
// On Released. SetFieldOfView() to 90;
UE_LOG(LogTemp, Warning, TEXT("Zoom out"));
}
I found a function for SetFieldOfView() but I have no idea how to simply get the player’s camera, or how to implement the function. Two hours in I just wish it was as simple as the Blueprint implementation
Any suggestions where to look, or what I’m missing?
Thanks for taking a look!