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);
}
}