Probably a really simple issue but I'm not seeing it. Just putting together a little Point & Click and I want an object to be destroyed when the user clicks on it with the mouse.
I'm not getting any errors and the gameObject is still there. keyBlue has no children and contains a mesh, a box collider and a custom script which is just rotating around.
function Update ()
{
if (Input.GetMouseButtonDown (0))
{
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit))
{
var modelhit = hit.collider.renderer.transform.name;
switch(modelhit)
{
case "keyBlue":
print("I hit the Blue Key");
bBlueKey = true;
Destroy(GetComponent(modelhit));
break;
}
}
}
}
The boolean is switched to true so it is running that chunk. Thanks in advance.