At first, I cannot use mouse controls, either. Then I rewrite the code.
//void AShipBase::CameraYawInput(float Val)
//{
// SpringArm->RelativeRotation.Yaw += Val;
//}
//void AShipBase::CameraPitchInput(float Val)
//{
// float NewPitch = (Val * -1.0f) + SpringArm->RelativeRotation.Pitch;
// SpringArm->RelativeRotation.Pitch = FMath::Clamp(NewPitch, CameraMinPitch, CameraMaxPitch);
//}
FRotator CurrentRate; //I define it in the ShipBase.h
void AShipBase::CameraPitchInput(float Val)
{
if (Val != 0)
{
CurrentRate.Pitch = FMath::Clamp(1.0f*Val, -1.0f, 1.0f);
FRotator NewRotation = SpringArm->GetComponentRotation() + CurrentRate;
if (NewRotation.Pitch < -42.0f)
NewRotation.Pitch = -42.0f;
if (NewRotation.Pitch > 2.f)
NewRotation.Pitch = 2.f;
SpringArm->SetWorldRotation(NewRotation);
}
}
void AShipBase::CameraYawInput(float Val)
{
if (Val != 0)
{
CurrentRate.Yaw= FMath::Clamp(-1.0f*Val,-1.0f, 1.0f);
FRotator NewRotation = SpringArm->GetComponentRotation() + CurrentRate;
SpringArm->SetWorldRotation(NewRotation);
}
}
Hey scorpio, when posting code, encapsulate the code with the
blocks. It's hard to read code when its not formatted in those code blocks. I'm going to take a look at the control logic again and make sure I didn't leave an error in the code.