Restrict FPP look

buhu

New member
Hello.
I need to have a custom viewtype in which I can limit player look around to certain degree.
I made a custom viewtype as stated in this topic: topic

first
How I can expose limit values in the inspector?... Looks like adding public float max and public float min in this viewtype don't make them exposed.
Adding floats similar to the pitch limits in FirstPerson.cs dont make them exposed too...
and second
What should I limit? Which float and how to do it?
 
How I can expose limit values in the inspector?... Looks like adding public float max and public float min in this viewtype don't make them exposed.
Adding floats similar to the pitch limits in FirstPerson.cs dont make them exposed too...
The inspector fields are drawn using inspector drawers. The FirstPersonInspectorDrawer draws the first person view type.

What should I limit? Which float and how to do it?
Take a look at the FreeLook ViewType for an example. In that ViewType it can restrict the yaw to a specified number of degrees. The FirstPerson ViewType can then restrict the pitch.
 
The inspector fields are drawn using inspector drawers. The FirstPersonInspectorDrawer draws the first person view type.
Ok, I have yaw in inspector... just out of curiousity - is this stated somewhere in documentation or I suppose to know that?


"Take a look at the FreeLook ViewType for an example. In that ViewType it can restrict the yaw to a specified number of degrees. The FirstPerson ViewType can then restrict the pitch."

I dont understand... I want to have restricted yaw and pitch - pitch is already there... which line of code from FreeLook I have to copy to FPP Combat viewtype to get restricted yaw? I'm not a programmer, I can copy and tick bools :p
 
This portion restricts yaw:

Code:
            // Update the rotation. The yaw may have a limit.
            if (Mathf.Abs(m_MinYawLimit - m_MaxYawLimit) < 360) {
                // Determine the new rotation with the updated yaw.
                var targetRotation = MathUtility.TransformQuaternion(m_CharacterRotation, Quaternion.Euler(m_Pitch, m_Yaw, 0));
                var diff = MathUtility.InverseTransformQuaternion(Quaternion.LookRotation(Vector3.forward, m_CharacterLocomotion.Up), targetRotation * Quaternion.Inverse(m_CharacterTransform.rotation));
                // The rotation shouldn't extend beyond the min and max yaw limit.
                var targetYaw = MathUtility.ClampAngle(diff.eulerAngles.y, horizontalMovement, m_MinYawLimit, m_MaxYawLimit);
                m_Yaw += Mathf.Lerp(0, Mathf.DeltaAngle(diff.eulerAngles.y, targetYaw), m_YawLimitLerpSpeed);
            } else {
                m_Yaw += horizontalMovement;
            }
 
Top