Exemple #1
0
    void Update()
    {
        if (isHidden)
        {
            return;
        }

        if (Input.GetMouseButton(0))
        {
            Vector2 swipe = (Vector2)Input.mousePosition - touchStart;

            // Change arrow rotation
            float angle = Vector2.SignedAngle(Vector2.up, swipe);
            arrowPivot.transform.rotation = Quaternion.Euler(0f, 0f, angle);

            // Change arrow size based on swipe magnitude
            float ySize = Mathf.Min(swipe.sqrMagnitude / minDragDistance, 1f);
            arrowPivot.transform.localScale = new Vector3(1f, ySize);

            // Change arrow color if angle is illegal
            if (BlobController.CheckJumpAngle(facingDirection, swipe,
                                              angleLimit))
            {
                arrowSprite.color = Color.white;
            }
            else
            {
                arrowSprite.color = Color.red;
            }
        }
    }