- Home /
 
               Question by 
               tomeriksson · Feb 25, 2018 at 12:01 PM · 
                variablesaccessing from any script  
              
 
              Get access and Flip between different variables from GameManager
I have a 6 different GameObject. 
 GameObject name: Axis1, Axis2, Axis3, etc. 
 
 I have an GameManager script that have all the static data for the Axis. 
 I create "one" script that i will put on all Axis GameObject. 
 The script will first check the name of the Gameobject that are attached too. 
 Then it will get all the axis info from GameManager. 
 
 I can create if statement to handle all the different axis. But it will repeat lot of same code. 
 Can I modify the line "rotationSpeedAxis = GameManager.singelton.rotationSpeedAxis1;" 
 So i dont need all the If statements?.
 
void Awake() {
     NameOfGameObject = gameObject.transform.name;              
     if (NameOfGameObject.Contains("Axis1"))                     
     {
         rotationSpeedAxis = GameManager.singelton.rotationSpeedAxis1;
         AxisCC = GameManager.singelton.Axis1CC;
} 
 
                 
                code.jpg 
                (142.5 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                