void HandleLookingDirection(float dt)
        {
            if (lookingDirectionParameters.followExternalReference)
            {
                targetLookingDirection = CharacterStateController.MovementReferenceForward;
            }
            else
            {
                switch (CharacterActor.CurrentState)
                {
                case CharacterActorState.NotGrounded:

                    if (CharacterActor.PlanarVelocity != Vector3.zero)
                    {
                        targetLookingDirection = CharacterActor.PlanarVelocity;
                    }

                    break;

                case CharacterActorState.StableGrounded:

                    if (CharacterStateController.InputMovementReference != Vector3.zero)
                    {
                        targetLookingDirection = CharacterStateController.InputMovementReference;
                    }
                    else
                    {
                        targetLookingDirection = CharacterActor.Forward;
                    }


                    break;

                case CharacterActorState.UnstableGrounded:

                    if (CharacterActor.PlanarVelocity != Vector3.zero)
                    {
                        targetLookingDirection = CharacterActor.PlanarVelocity;
                    }

                    break;
                }
            }


            Quaternion targetDeltaRotation  = Quaternion.FromToRotation(CharacterActor.Forward, targetLookingDirection);
            Quaternion currentDeltaRotation = Quaternion.Slerp(Quaternion.identity, targetDeltaRotation, 10 * dt);



            {
                float angle = Vector3.Angle(CharacterActor.Forward, targetLookingDirection);

                if (CustomUtilities.isCloseTo(angle, 180f, 0.5f))
                {
                    CharacterActor.Forward = Quaternion.Euler(0f, 1f, 0f) * CharacterActor.Forward;
                }

                CharacterActor.Forward = currentDeltaRotation * CharacterActor.Forward;
            }
        }
        void GetContactsInformation()
        {
            bool wasCollidingWithWall = characterCollisionInfo.wallCollision;
            bool wasCollidingWithHead = characterCollisionInfo.headCollision;

            wallContacts.Clear();
            headContacts.Clear();

            for (int i = 0; i < Contacts.Count; i++)
            {
                Contact contact = Contacts[i];

                float verticalAngle = Vector3.Angle(Up, contact.normal);

                // Get the wall information -------------------------------------------------------------
                if (CustomUtilities.isCloseTo(verticalAngle, 90f, CharacterConstants.WallContactAngleTolerance))
                {
                    wallContacts.Add(contact);
                }


                // Get the head information -----------------------------------------------------------------
                if (verticalAngle >= CharacterConstants.MinHeadContactAngle)
                {
                    headContacts.Add(contact);
                }
            }


            if (wallContacts.Count == 0)
            {
                characterCollisionInfo.ResetWallInfo();
            }
            else
            {
                Contact wallContact = wallContacts[0];

                characterCollisionInfo.wallCollision = true;
                characterCollisionInfo.wallAngle     = Vector3.Angle(Up, wallContact.normal);
                characterCollisionInfo.wallContact   = wallContact;

                if (!wasCollidingWithWall)
                {
                    if (OnWallHit != null)
                    {
                        OnWallHit(wallContact);
                    }
                }
            }


            if (headContacts.Count == 0)
            {
                characterCollisionInfo.ResetHeadInfo();
            }
            else
            {
                Contact headContact = headContacts[0];

                characterCollisionInfo.headCollision = true;
                characterCollisionInfo.headAngle     = Vector3.Angle(Up, headContact.normal);
                characterCollisionInfo.headContact   = headContact;

                if (!wasCollidingWithHead)
                {
                    if (OnHeadHit != null)
                    {
                        OnHeadHit(headContact);
                    }
                }
            }
        }