Hi guys, i was wondering i have a game object which has about 10 game objects to it and i was wondering is there an easy way to turn them of by script. because at the moment i have like so many variables created at the top which hold the parts and then turn them off when i press a key. Now is there a line of code that can turn them all of at once was thinking can you use
GameObject.Find to do this
i would really appreciate if someone could really help me :) thanks in advance guys MCHALO
oh yea by the way here is my script:
var Scope : GameObject;
var ScopeSig552 : GameObject;
var M4a1: GameObject;
var M4a1Scope : GameObject;
var M4a1SightAim : GameObject;
var M4a1Sight2 : GameObject;
var LeftHand : GameObject;
var RightHand : GameObject;
var Gun : GameObject;
var Sig552 : GameObject;
var M4a1Sight1 : GameObject;
var breech : GameObject;
var bullets : GameObject;
var CaseForGun: GameObject;
var frame: GameObject;
var magazine: GameObject;
var safety: GameObject;
var sights: GameObject;
var stock: GameObject;
var scopeDelay : int = 2;
var GunScope : boolean = false;
function Update () {
if(Input.GetMouseButtonDown (2)){
GunScope = true;
LeftHand.active = true;
RightHand.active = true;
M4a1SightAim.active = false;
M4a1Sight2.active = false;
M4a1.active = false;
Gun.active = false;
M4a1Scope.active = false;
M4a1Sight1.active = false;
Sig552.active = true;
breech.active = true;
bullets.active = true;
CaseForGun.active = true;
frame.active = true;
magazine.active = true;
safety.active = true;
sights.active = true;
stock.active = true;
}
if(Input.GetKey(KeyCode.Alpha1 )){
GunScope = false ;
LeftHand.active = true;
RightHand.active = true;
M4a1SightAim.active = true;
M4a1Sight2.active = true;
M4a1.active = true;
Gun.active = true;
M4a1Scope.active = true;
M4a1Sight1.active = true;
Sig552.active = false;
breech.active = false;
bullets.active = false;
CaseForGun.active = false;
frame.active = false;
magazine.active = false;
safety.active = false;
sights.active = false;
stock.active = false;
}
if(Input.GetMouseButtonUp(1)){
if(GunScope == true){
Scope.active = false;
ScopeSig552.active = false;
}
if(GunScope == false){
Scope.active = false;
ScopeSig552.active = false;
}
}
if(Input.GetMouseButtonDown(1)){
if(GunScope == true){
Scope.active = false;
ScopeSig552.active = true;
}
if(GunScope == false){
Scope.active = true;
ScopeSig552.active = false;
}
}
}
function OnCollisionEnter (bomb: Collision){
}