Hello!
I have a script that is suppossed to find all objects in the scene with the tag “Bar”
and change a variable of the script that they have. But it doesn’t work. Any help?
var baricades = GameObject.FindGameObjectsWithTag("Bar");
var theScript = baricades.GetComponent("Js_Bars");
theScript.hitted = true;
Like this? you are sure this is correct? it gives me errors... var baricades = GameObject.FindGameObjectsWithTag("Bar"); foreach(var x in barricades) { var theScript = x.GetComponent.< Js_Bars >(); theScript.hitted = true; }
– smirlianosAre you writing in JavaScript? Sorry, got used to C#, replace
– moonstruckforeachforfor.Thanks, now it works!
– smirlianos