Beispiel #1
0
    void DragRelease()
    {
        lr.positionCount = 0;

        Vector3 dragReleasePos = Camera.main.ScreenToWorldPoint(touch.position);

        dragReleasePos.z = 0f;
        Vector3 force        = dragStartPos - dragReleasePos;
        Vector3 clampedForce = Vector3.ClampMagnitude(force, maxDrag) * power;

        // -- only do arrow if force is not (0,0) because that is a tap
        if ((Vector2)force != Vector2.zero)
        {
            // -- start arrow shooting animation
            curArrowController.ReleaseAnimation();

            // -- must change to dynamic for force to be added
            arrowRB.isKinematic = false;
            arrowRB.AddForce(clampedForce, ForceMode2D.Impulse);

            // -- start reloading time
            curReloadTime = reloadTime;
            reload        = true;       // -- tell update function to reload on next frame

            // -- start UI timer
            timer.StartTimer(reloadTime);
        }
        // -- if it's a tap
        else
        {
            // -- put arrow back to it's pre loading spot
            curArrowController.PutBackAnimation();
        }
    }