I am trying to create a new temporary box collider at a raycasts hit location on click however cannot seem to make a new box collider in script to do so.
Ray v = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit = new RaycastHit();
if(Physics.Raycast(v,out hit,100.0f))
{
MeshFilter mf = (MeshFilter)hit.collider.gameObject.GetComponent(typeof(MeshFilter));
if(mf)
{
//create a copy of the mesh to trim
Mesh decalMesh = Mesh.Instantiate(mf.mesh) as Mesh;
BoxCollider bc = new BoxCollider(); //<--- bc = NULL
}
What am I missing about creating a box collider that I can use to test against a mesh's triangles?