Hey guys,
I am pretty new to UE4 and am currently working on a project which requires a player being able to control a flying pawn through the use of the Rift’s HMD Head tracking. The way I’m able to accomplish this is by adding a cube in front of the camera and then lerping the player body’s rotation to face towards the box. This works well for Yaw but not so much for the Pitch. As soon as the player’s Pitch rotation nears the poles the camera starts jittering around and spins out of control.
Let me show the current code in use :
FVector _CrosshairLocation = CrosshairComponent->GetComponentLocation();
FVector _ParentLocation = RootComponent->GetComponentLocation();
FVector _Dir = (_CrosshairLocation - _ParentLocation);
_Dir.Normalize();
FQuat _DirQuat = FQuat(_Dir.Rotation());
FQuat _RootQuat = RootComponent->GetComponentRotation().Quaternion();
FQuat _ResultantQuat = FMath::Lerp(_RootQuat, _DirQuat, RotationSpeed * DeltaSeconds);
RootComponent->SetWorldRotation(_ResultantQuat.Rotator());
So does anyone have any idea on how I go about having a good 4 DOF flight mode?