Example #1
0
    public void OnFingerSwipe(Lean.LeanFinger finger)
    {
        // Raycast information
        var ray = finger.GetStartRay();
        var hit = default(RaycastHit);

        // Was this finger pressed down on a collider?
        if (Physics.Raycast(ray, out hit, float.PositiveInfinity, LayerMask) == true)
        {
            // Was that collider this one?
            if (hit.collider.gameObject == gameObject)
            {
                // Get the rigidbody component
                var rigidbody = GetComponent <Rigidbody>();

                // Add force to the rigidbody based on the swipe force
                rigidbody.AddForce(finger.ScaledSwipeDelta * ForceMultiplier);
            }
        }
    }