コード例 #1
0
    /// <summary>
    /// défini si on est en grip, moving or not
    /// </summary>
    private void TryToTurn()
    {
        Vector3 inputOfPlayer = playerInput.GetDirInput();

        if (playerGrip.Gripped)
        {
            IsGripped();
        }
        else if (inputOfPlayer.x == 0)
        {
            NotMoving();
        }
        else
        {
            IsMoving(inputOfPlayer.x);
        }

        if (!playerGrip.Gripped && playerPenduleMove.IsAirTenseOrInCoolDown())
        {
            penduleMove = ropeHandler.GetVectorFromPlayer(playerController.IdPlayer);



            if (worldCollision.IsOnFloor())
            {
                penduleMove = new Vector3(0, 1, 0);
                Debug.Log("ici on floor ?");
                penduleMove = Vector3.up;
                //childAnim.localEulerAngles = new Vector3(0, 0, 0);
                penduleChildRotate = new Vector3(0, 0, 0);
                return;
            }
            //childAnim.localEulerAngles = new Vector3(0, 0, 0);
            Vector3 dirReference = playerInput.GetDirInput();

            int rightMove = 0;
            dirMove = QuaternionExt.GetTheGoodRightAngleClosestNoClose(penduleMove, dirReference, 10f, out rightMove);

            if (dirMove == Vector3.zero)
            {
                rightMove = 0;
                dirMove   = new Vector3(0, -1, 0);
                Debug.Log("ici no input en pendule...");
            }

            //childAnim.rotation = Quaternion.Euler(new Vector3(0, 0, 0));

            if (rightMove == -1)
            {
                //childAnim.localEulerAngles = new Vector3(0, -90, 0);
                penduleChildRotate = new Vector3(0, 270, 0);
            }
            else if (rightMove == 1)
            {
                //childAnim.localEulerAngles = new Vector3(0, 90, 0);
                penduleChildRotate = new Vector3(0, 90, 0);
            }
            else
            {
                //childAnim.localEulerAngles = new Vector3(0, 0, 0);
                penduleChildRotate = new Vector3(0, 0, 0);
            }
        }
        else
        {
            penduleMove = Vector3.up;
            //childAnim.localEulerAngles = new Vector3(0, 0, 0);
            penduleChildRotate = new Vector3(0, 0, 0);
        }
    }