I have no idea why this isn’t working… if anyone can help me, I really appreciate it!
my script attached to my camera:
using UnityEngine;
using System.Collections;
public class placingObjectScript : MonoBehaviour
{
public bool treeSelected = true;
public GameObject[] tree;
void Update ()
{
if(Input.GetMouseButtonDown(0))
{
Ray ray;
RaycastHit hit;
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray, out hit, 1 << 3))
{
if(treeSelected && hit.collider.tag == "placableGround")
{
Instantiate(tree[Random.Range (0, tree.Length)], hit.point, Quaternion.identity);
}
}
}
}
}
I have assigned everything to the default layer, and then the camera to Ingore Raycast.
The camera has a collider, and without using layers, the trees will spawn on the camera’s collider.
At the moment, when you click, nothing happens. It works when I get rid of the camera collider and the layer mask bit, but I really need a camera collider…