Hello, what I’m trying to do is disable a script from another script. The main reason i need to do this is because i’m making a weapon controller, and i have one script that controls 3 of them. 1 for standard bullet, 2 for a smoke grenade, and 3 for a EM bomb. Which disables all guns within a specific range (just and idea). Now i need to disable the script because each script controls a specific weapon. I’ve tried like almost everything and i keep getting the same error: “Object reference not set to an instance of an object”.
I’ve tried all these:
GetComponent(Standard_Bullet).enabled = true;
Doesn’t work. I’ve also tried:
gameObject.GetComponent(Standard_Bullet).enabled = true;
Once again doesn’t work. I’ve tried:
public var StandardBull : Standard_Bullet;
GetComponent(StandardBull).enabled = true;
Still doesn’t work. So that’s why i’m asking on here. Keep in mind i am using C#.
Also the script i tried are within a If statement, for instance:
public var StandardBull : Standard_Bullet;
public var CurrentWeapon : int;
function Update (){
if (CurrentWeapon == 1){
GetComponent(StandardBull).enabled = true;
}
}
Also CurrentWeapon is controlled by the MouseWheel, and is clamped from 1 to 3.
Thanks In Advance!