I think I’m really misunderstanding how AddInputVector is supposed work. I have a pawn with a camera that I’m trying to put RTS style movement on. WASD works fine for flying around but I’m trying to add zooming in and out using a parabolic function that I want the camera pawn to move along. The idea is when you zoom in the camera it will go down in height and a little towards the focus of the camera (left side of a parabolic curve). I’ve been trying to add huge coefficients to AddInputVector but the camera still barely moves when scrolling on the mouse wheel. Here is the code I have.
void APlayerIsometric::Zoom(const FInputActionValue& Value) {
UE_LOG(LogTemp, Warning, TEXT("Input Value: %f"), Value.Get<float>());
if (Controller) {
FVector OldPos = GetActorLocation();
float Input = Value.Get<float>();
if (OldPos.Z > MinHeight && OldPos.Z < MaxHeight) {
float TargetZ = OldPos.Z + -1.0f * Input * ZoomSensitivity;
TargetZ = FMath::Clamp(TargetZ, MinHeight, MaxHeight);
float NewZ = FMath::Lerp(OldPos.Z, TargetZ, 0.1);
//z = ((x^2) / 10) + 300
double EqResult = UKismetMathLibrary::Sqrt(((NewZ - 300.0f) * 10));
FRotator Rotation = Controller->GetControlRotation();
FRotator YawRotation = { 0, Rotation.Yaw, 0 };
FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
FVector UpDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Z);
AddMovementInput(ForwardDirection, (EqResult - OldPos.X) / OldPos.X);
AddMovementInput(RightDirection, (EqResult - OldPos.Y) / OldPos.Y);
float Zcalc = FMath::Abs(NewZ - OldPos.Z) * Input * -1.0f * 10.0f* 1000000.0f;
MovementComponent->AddInputVector(UpDirection * INT32_MAX / 2 , false);
float NewPitch = FMath::Atan(OldPos.Z * FMath::Tan(Rotation.Pitch) / NewZ);
//AddControllerPitchInput(NewPitch - Rotation.Pitch);
}
}
}
I was mostly trying to play around with adjusting the height before touching the other axes. Ignore the part with pitch I have to fix that after this.