- Home /
Disable gun if it is not mine?
I tried using this script here to check if I got the gun and if I did then the scripts are enabled but it doesnt work.
SCRIPT:
function OnTriggerEnter(hit:Collider)
{
if(hit.gameObject.tag == "Player")
{
gameObject.Find("BSpawner").GetComponent("Shoot").enabled = true;
gameObject.Find("Muzzle").GetComponent("Shoot").enabled = true;
}
else
{
gameObject.Find("BSpawner").GetComponent("Shoot").enabled = false;
gameObject.Find("Muzzle").GetComponent("Shoot").enabled = false;
}
}
Comment
Answer by Griffo · Sep 22, 2012 at 04:24 PM
Try ..
gameObject.Find("BSpawner").GetComponent("Shoot").SetActiveRecursively(true);
gameObject.Find("Muzzle").GetComponent("Shoot").SetActiveRecursively(true);
what does the "SetActiveRecursively" do
and shouldnt it be SetActiveRecursively = true?
I think "Shoot" is a script attached to the game object. SetActiveRecursively only works for game objects.
offcource its a script thats why i tried using GetComponent
Your answer
Follow this Question
Related Questions
[c#]How to start a coroutine after deactivating and re-enabling script? 0 Answers
how to disable patent components incode 0 Answers
CS0119 Error for Script Disable? 1 Answer
Image.enable not working properly 1 Answer
Disable & Re-enable Script 1 Answer