I have created a plane in my scene that can be used to detect collision. I am trying to create a raycast on mouse click and detect if it's collided with that game object. Then instantiate another game object. I can't seem to figure out how to do this.
// Update is called once per frame
void Update()
{
if(Input.GetButtonDown("Fire1"))
{
Ray ray = new Ray(Camera.main.transform.position, Vector3.Normalize(near));
Vector3 near = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
RaycastHit[] raycastHits = Physics.RaycastAll(ray);
if(raycastHits == GameObject.FindGameObjectWithTag("S_Plane"))
{
}
}
}