I can’t figure out why only the ZoomOut function is not working properly with the script. The ZoomIn works completely fine.
Any ideas/help/sad stories? Be easy on me though, I’ve just started learning C++ about 2 weeks ago. It just seems that with the ZoomOut, the camera is NOT increasing it’s TargetArmLength appropriately by 50.
void ATest3rdPersonCharacter::ZoomIn()
{
if (CameraBoom->TargetArmLength > 100.0f)
{
bIsInFPS = false;
CameraBoom->TargetArmLength = (FMath::FInterpTo(CameraBoom->TargetArmLength, -50.f, GDeltaTime, 3.0));
CameraBoom->SetRelativeLocation(FMath::VInterpTo(CameraBoom->RelativeLocation, (FVector(0.f, 75.f, 75.f)), GDeltaTime, 3.0));
}
else if (CameraBoom->TargetArmLength >= 50.0f)
{
bIsInFPS = false;
CameraBoom->TargetArmLength = (FMath::FInterpTo(CameraBoom->TargetArmLength, -50.f, GDeltaTime, 3.0));
CameraBoom->SetRelativeLocation(FMath::VInterpTo(CameraBoom->RelativeLocation, (FVector(0.f, 0.f, 50.f)), GDeltaTime, 3.0));
}
else
{
bIsInFPS = true;
}
}
void ATest3rdPersonCharacter::ZoomOut()
{
if (CameraBoom->TargetArmLength < 500)
{
bIsInFPS = false;
CameraBoom->TargetArmLength = (FMath::FInterpTo(CameraBoom->TargetArmLength, 50.f, GDeltaTime, 3.0));
CameraBoom->SetRelativeLocation(FMath::VInterpTo(CameraBoom->RelativeLocation, (FVector(0.f, 75.f, 75.f)), GDeltaTime, 3.0));
}
else
{
bIsInFPS = false;
CameraBoom->SetRelativeLocation(FVector(0.f, 25.f, 100.f));
CameraBoom->TargetArmLength = 500.0;
}
}
It seems I may have figured it out.
This works much much better, almost like a charm.
void ATest3rdPersonCharacter::ZoomIn()
{
if (CameraBoom->TargetArmLength > 100.0f)
{
bIsInFPS = false;
CameraBoom->TargetArmLength = (FMath::FInterpTo(CameraBoom->TargetArmLength, -100.f, GDeltaTime, 10.0));
CameraBoom->SetRelativeLocation(FMath::VInterpTo(CameraBoom->RelativeLocation, (FVector(0.f, 75.f, 75.f)), GDeltaTime, 3.0));
}
else if (CameraBoom->TargetArmLength >= 50.0f)
{
bIsInFPS = false;
CameraBoom->TargetArmLength = (FMath::FInterpTo(CameraBoom->TargetArmLength, -100.f, GDeltaTime, 10.0));
CameraBoom->SetRelativeLocation(FMath::VInterpTo(CameraBoom->RelativeLocation, (FVector(0.f, 0.f, 50.f)), GDeltaTime, 3.0));
}
else
{
bIsInFPS = true;
}
}
void ATest3rdPersonCharacter::ZoomOut()
{
if (bIsInFPS)
{
CameraBoom->SetRelativeLocation(FVector(0.f, 25.f, 100.f));
}
if (CameraBoom->TargetArmLength <=500)
{
bIsInFPS = false;
CameraBoom->TargetArmLength = (FMath::FInterpTo(CameraBoom->TargetArmLength, 500.f, GDeltaTime, 10.0));
CameraBoom->SetRelativeLocation(FMath::VInterpTo(CameraBoom->RelativeLocation, (FVector(0.f, 25.f, 100.f)), GDeltaTime, 3.0));
}
else
{
bIsInFPS = false;
CameraBoom->SetRelativeLocation(FVector(0.f, 25.f, 100.f));
CameraBoom->TargetArmLength = 500.0;
}
}