- Home /
how to destroy two game objects when selected
i have two game objects i want to select one game object and when i select second game object i want both of them to be destroyed but when i select objectA first and then select ObjectB second it is happening how i want.But If i select objectB first then with out selecting the objectA both the objects are destroying..here i provide some code a help would be grateful..thanks.
0 private void Update()
{
if(Selection$$anonymous$$anager23.IsSelected(gameObject)== objectA&& Selection$$anonymous$$anager23.IsSelected(gameObject)== objectB)
{
DestroyObject(objectB);
DestroyObject(objectA);
}
if ( Input.Get$$anonymous$$ouseButtonDown(0))
{
RaycastHit hit;
ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if ( Physics.Raycast( ray,out hit, 100 ) )
{
if ( hit.collider.gameObject.renderer )
{
hit.collider.gameObject.renderer.material.color = Color.magenta;
}
}
}
} this is the code i am using...
Your answer
Follow this Question
Related Questions
selecting multable weapons 1 Answer
Instantiated prefab references point to first prefab instantiated 3 Answers
Object Tower not selecting right object. 1 Answer
Displaying precision edges of a mesh at runtime? 0 Answers
Scripting error 1 Answer