Hello everyone,
I’m hoping this is an easy answer, but can’t find any examples quite like what I’m trying to achieve, and I’m getting some odd problems. I think they might have to do with how I’m accessing the variables. Here is the problem: I have 2 functions bound to the Mouse X and Y of the InputComponent of a PlayerController, nothing fancy. These target the SpringArm component of the controllers current character. One function adjusts Pitch, the other Yaw. Oddly enough, somethings things works as they should. Other times, I get wildly a wildly spinning camera, one that slowly creeps, or one that doesn’t respond at all. I was attempting to debug this and have found that by wrapping the functions below in #pragma optimize("", off/on) seems to have corrected the problem. Can anyone give some insight into what might be happening here?
void ASaSPlayerController::CameraYaw(float Value)
{
ASaSCharacter* MyCharacter = Cast<ASaSCharacter>(GetCharacter());
USpringArmComponent* MySpringArm = MyCharacter->GetCameraBoom();
FRotator BoomRotation = MySpringArm->GetComponentRotation();
FRotator SpringArmRotationChange;
SpringArmRotationChange.Yaw = Value;
BoomRotation += SpringArmRotationChange;
MySpringArm->SetWorldRotation(BoomRotation);
}
void ASaSPlayerController::CameraPitch(float Value)
{
ASaSCharacter* MyCharacter = Cast<ASaSCharacter>(GetCharacter());
USpringArmComponent* MySpringArm = MyCharacter->GetCameraBoom();
FRotator BoomRotation = MySpringArm->GetComponentRotation();
FRotator SpringArmRotationChange;
SpringArmRotationChange.Pitch = Value;
BoomRotation += SpringArmRotationChange;
MySpringArm->SetWorldRotation(BoomRotation);
}