- Home /
Question by
NadhmiPrince · Apr 23, 2015 at 06:25 PM ·
transformgetcomponent
Transform[].GetComponent HELP!
Hi, I have like 10 engines, what I want to do is to disable a script called "EnginePower" for all these 10 engine. I know that I can use: var engine1 : Transform; var engine2 : Transform; var engine3 : Transform; var engine... : Transform;
function Start()
{
engine1.GetComponent("EnginePower").enabled=false;
engine2.GetComponent("EnginePower").enabled=false;
engine3.GetComponent("EnginePower").enabled=false;
engine....GetComponent("EnginePower").enabled=false;
}
But I'd like to do it this way: var engine : Transform[]:
function Start()
{
engine[].GetComponent("EnginePower").enabled=false;
}
But it dosen't seem to be working
Can someone help me pleaseeeee. I need this so much Thanks.
Comment
Your answer
Follow this Question
Related Questions
Having trouble understanding parenting with componants 0 Answers
GetComponent for a stored transform. 0 Answers
Getting mesh renderer from a Transform(not "transform") 1 Answer
numerous errors with super basic door transform 1 Answer
NULL REFERENCE EXCEPTION,NULL REFERENCE EXCEPTION while accessing child objects unity2D 0 Answers