Hi people,
I am currently trying to implement a basic VR head motion in my project. The problem is that I am not comfortable with the sensor values provided. For instance, I roll my camera with respect to gravity but the gravity vector is affected by the other forces as well(when I turn around myself for instance) and this causes my camera to roll even if I do not roll the phone. I could not find a way to remove those other forces effecting gravity vector. Any idea?
void APlayerVR::PerformRoll(FVector Gravity)
{
FRotator CameraRotation = CameraComponent->GetComponentRotation();
float CurrentRoll = CameraRotation.Roll;
float TargetRoll = Gravity.Y * 10.0f;
CameraRotation.Roll = FMath::Lerp(CurrentRoll, TargetRoll, 0.1f);
CameraComponent->SetWorldRotation(CameraRotation);
}