Here is my code:
using UnityEngine;
using System.Collections;
public class Instantiate : MonoBehaviour {
//position and rotation can be equal to that of an object if you use the object's ID.
Ray ray;
RaycastHit hit;
public GameObject Sphere;
void Update ()
{
ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray, out hit))
{
if (Input.GetMouseButtonDown (0))
{
Instantiate (Sphere, hit.point + new Vector3(0, 0.5f, 0), Quaternion.identity);
}
}
}
}
How can I make it so that when the ray hits a sphere clone, the instantiation code does not execute? Keep in mind that I am new to Unity, so try to use simple terms on me.