예제 #1
0
    public void DEnd()
    {
        if (!ball.ballIsRolling)
        {
            dragendPos = Input.mousePosition;             // Assigns value to dragstartPos (see decleration)
            timeEnd    = Time.time;

            float dragDuration    = timeEnd - timeStart;
            float launchVelocityX = (dragendPos.x - dragstartPos.x) / dragDuration;             //gets the velocity based on speed and position of drag
            float launchVelocityZ = (dragendPos.y - dragstartPos.y) / dragDuration;             // tl:dr velocity based on dragging of ball

            Vector3 finalVelocity = new Vector3(launchVelocityX, 0, launchVelocityZ);           // gets the velocity the ball will be launched
            if (ball.ballIsRolling == false)
            {
                ball.Roll(finalVelocity);                  // Rolls ball on end of drag, DUH
            }
        }
    }