Question by 
               Lieferjunge · Mar 31, 2016 at 03:32 AM · 
                gameobjectsscore systemweaponsswitching  
              
 
              How to Switch GameObjects (Weapons) by reaching a specific amount of score?
Hi! I am running nuts with the GameObject Basics. There are so many solutions in the internet that I hardly get neither to work with my problem.
You will find 4 attempts in the if braket further down.
Do you have a tutorial about GameObjects which is concerning my problem? I found out that I cannot just set it active, but I have no clue how referencing looks like.
I want my weapon to switch from pistol to rilfe when the player have reached 150 points. The Pistol and the Rilfe are in a prefab of the Player GameObject. (Simple Military Asset Store)
Thank you in advance! Lieferjunge
public class ScoreManager : MonoBehaviour { public static int score; // The player's score. GameObject rifle; GameObject pistol;
     Text text;                      // Reference to the Text component.
 
 
     void Awake()
     {
         // Set up the reference.
         text = GetComponent<Text>();
 
         // Reset the score.
         score = 0;
 
         rifle = GameObject.FindGameObjectWithTag("Rifle");
         pistol = GameObject.FindGameObjectWithTag("Pistol");
     }
 
 
     void Update()
     {
         // Set the displayed text to be the word "Score" followed by the score value.
         text.text = "Score: " + score;
 
         if (score >= 150)
         {
             //Instantiate(rifle, new Vector3(?,?,?), Quaternion.identity);
             //pistol.SetActive(false);
             //rifle.SetActive(true);
            //rifle.GameObject.SetActive(true);
         }
     }
 }
 
              
               Comment
              
 
               
              Your answer