using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public static class TouchUtilities
{
    public static Vector3 GetTouchPositionOnPlane(Plane plane, Vector2 touchPosition)
    {
        Ray ray = Camera.main.ScreenPointToRay(touchPosition);
        // Plane.Raycast stores the distance from ray.origin to the hit point in this variable:
        float distance = 0;
        // if the ray hits the plane...
        if (plane.Raycast(ray, out distance))
        {
            // get the hit point:
            return ray.GetPoint(distance);
        }
        else
        {
            // Return Zero if no intersection occurs
            return Vector3.zero;
        }
    }
}
