Question by 
               Iwastheturkey3 · Nov 17, 2015 at 04:25 PM · 
                javascriptmath  
              
 
              Unkown Identifier: 'Math'.
Im trying to get a random GameObject to spawn based off of what value is pulled from my array. But Untiy is returning the error "Assets/SpawnScript.js(27,39): BCE0005: Unknown identifier: 'Math'." This is my code:
var powerUp = ['FireSpeed','Movement','SlowTime'];
function PowerUp()
{ 
 var rand = powerUp[Math.floor(Math.random() * powerUp.length)];  
 if (rand === 'FireSpeed') 
 
 {  
     Instantiate(fireSpeed, transform.position, transform.rotation);  
     GetComponent.<Rigidbody2D>().AddForce(transform.up);  
 }  
 if  (rand === 'Movement')  
 {  
     Instantiate(movement, transform.position, transform.rotation);  
     GetComponent.<Rigidbody2D>().AddForce(transform.up);
 }
 if (rand === 'SlowTime')
 {
     Instantiate(slowTime, transform.position, transform.rotation);
     GetComponent.<Rigidbody2D>().AddForce(transform.up);        
 }
}
               Comment
              
 
               
              Answer by _Game_Dev_Dude_ · Nov 17, 2015 at 04:27 PM
http://docs.unity3d.com/ScriptReference/Mathf.html
The unity math library can be referenced with Mathf keyword but it does not contain the Random functionality.
http://docs.unity3d.com/ScriptReference/Random.html
This one does.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                