I am having trouble using broadcast message to deselect and deparant multiple objects.
when selected the gameobjects are parented to a gO named “selected”
and upon clicking on terrain or single unit, all selected parents are set to 0.
[Sender]…
if(Physics.Raycast(ray, hit))
if(hit.transform.CompareTag("UNIT")){
selected.BroadcastMessage("Deselect",options);
hit.transform.BroadcastMessage("Select",options);
}
if(hit.transform.CompareTag("Terrain")){
selected.BroadcastMessage("Deselect",options);
}
[Reciever]…
function Select () {
selected = true;
transform.parent = selectionParent;
}
function Deselect() {
selected = false;
transform.parent = null;
}
But for some reason only one or two is deselected at a time???