- Home /
Question by
aerhx · Apr 15, 2013 at 02:25 AM ·
javascriptgameobjectdestroy
JS file deleting multiple game objects
So I'm creating a script that will delete an object. Each object defines the number as a tag and the pageNum as a variable. Yet when I click either one, it deletes both of the objects.
var pageNum: float = 0;
function Start(){
}
function Update(){
if ( Input.GetMouseButtonDown(0)){
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var select = GameObject.FindWithTag("page-"+pageNum).transform;
if (Physics.Raycast (ray, hit, 3.0)){
Destroy(GameObject.FindWithTag("page-"+pageNum));
}
}
}
Comment