What I’m working on right now involves the user selecting ball objects. The user is able to select multiple instances of them. Right now, I’m storing the selection as a boolean variable inside a script for the ball object like so:
var selected = false;
function OnMouseDown ()
{
if(selected == false)
{
selected = true;
}
}
However, I have a game master script and I want to have it so when the user enters a key, it will destroy all the objects that were previously selected.
My initial plan was to tag the object when selected by the user, and then destroy all the objects with the selected tag, but as far as I can tell, you can not tag objects at runtime. Does anyone have an idea for an alternative method?
(Also I’m working in JavaScript in case anyone wants to provide code example.)