How do you all manage character head movement?

The code supplied on the Oculus Rift Separate View page is is based on what Ground Branch uses for the Oculus Rift, Freeaim and Freelook.

It doesn’t matter if you use a camera attached to the player model or not, as the actual view rotation comes from by the player controller.

With a few changes, it can support anything you like - Rift, TrackIR, button & mouse based freelook etc.

For freelook, take the DeltaRot and apply it to the players view rotation instead of the controllers rotation.
Something like this:



    // Calculate Delta to be applied on ViewRotation
    FRotator DeltaRot(RotationInput);
 
    FRotator NewControlRotation = GetControlRotation();
    FRotator NewViewRotation = GetViewRotation();
    
    if (PlayerCameraManager)
    {
        if (bFreeLook)
        {
            PlayerCameraManager->ProcessViewRotation(DeltaTime, NewViewRotation, DeltaRot);
            
            // Limit how far we can turn our head before our torso begins to turn too.
            const float YawDif = FRotator::NormalizeAxis(NewAimRotation.Yaw - NewViewRotation.Yaw);
            const float MaxYawDif = 85.0f;
                
            float AddDeltaYaw = 0.0f;
            
            if (YawDif > MaxYawDif)
            {
                AddDeltaYaw = YawDif - MaxYawDif;
            }
            else if (YawDif < -MaxYawDif)
            {
                AddDeltaYaw = YawDif + MaxYawDif;
            }

            NewAimRotation.Yaw -= AddDeltaYaw;
            NewViewRotation.Yaw = FMath::ClampAngle(NewViewRotation.Yaw, NewAimRotation.Yaw - MaxYawDif, NewAimRotation.Yaw + MaxYawDif);
        }
        else
        {
            PlayerCameraManager->ProcessViewRotation(DeltaTime, NewControlRotation, DeltaRot);

            // We've stopped freelooking recently - reset the head angles.
            if (CenterHeadTime > 0.0f)
            {
                float Alpha = (TimeToCenterHead - CenterHeadTime) / TimeToCenterHead;
                CenterHeadTime = FMath::Max(0.0f, CenterHeadTime - DeltaTime);
                NewViewRotation = FMath::Lerp(NewViewRotation, FreeAim, Alpha);
            }
            else
            {
                NewViewRotation = NewControlRotation;
            }
        }
    }
 
    SetControlRotation(NewControlRotation);

    // If our view and aim are different, call SetViewRotation().
    if (NewViewRotation != NewAimRotation)
    {
        SetViewRotation(NewViewRotation);
    }


bFreelook, CenterHeadTime etc are set by a Freelook command, all within the player controller.

Hope it helps.