Setting a maximum rotation speed

Cheo

Active member
Hello, is there a parameter for limiting the rotation speed of a character no matter the input given ? Or what would be the best way to go about it ? I suppose it would only take a few lines of code in Ultimate Character Locomotion or Character Locomotion but I'm not good with stuff like quaternions. Thanks in advance.
 
Alright, big thanks to @DankP3 for reminding me of a simple trick I had completely forgotten about : since in my personal case the character is using the third person combat view and control types, all that was needed was to create a Vector2 and use it to clamp the horizontalMovement and verticalMovement in the view type's Rotate function :

C#:
        public override Quaternion Rotate(float horizontalMovement, float verticalMovement, bool immediatePosition)
        {

            horizontalMovement = Mathf.Clamp(horizontalMovement, rotationClamp.x * -1, rotationClamp.x);
            verticalMovement = Mathf.Clamp(verticalMovement, rotationClamp.y * -1, rotationClamp.y);

            // The character may be controlling the rotation rather than the camera.
            if (m_RotateWithCharacter) {
                m_BaseRotation = m_CharacterRigidbody.rotation;
            } else {
                m_Yaw += horizontalMovement;
            }


            return base.Rotate(horizontalMovement, verticalMovement, immediatePosition);
        }

Now a simple Vector2 allows for the recreation of Resident Evil's slow and cumbersome rotations !

However I am not sure this method can be applied to all view and control types, and in any case this maximum rotation parameter should really be part of UCC.
 
Top