In MouseWorld add variable:
static Vector3 lastPosition = Vector3.zero;
and change GetPosition() to:
public static Vector3 GetPosition()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Physics.Raycast(ray, out RaycastHit hit, float.MaxValue, instance.mousePlaneLayerMask);
if (hit.collider != null)
{
lastPosition = hit.point;
}
return lastPosition;
}
Now you will remain in place if your mouse click doesn’t hit the LayerMask.