I don’t know why this won’t compile.
#pragma strict
function Start () {
var randomNumber = Random.Range(0, 2);
if (randomNumber <= 0,5) {
Debug.Log("Shoot right");
rigidbody2.AddForce (new Vector2 (80,10));
}
else {
Debug.Log("Shoot left");
rigidbody2.AddForce (new Vector2 (-80,-10));
}
}
function Update () {
}
kat0r
2
if (randomNumber <= 0,5) {
You used a “,” instead of a “.” here.
You should learn to use and read the error messages properly since they tell you everything you need to know.
Your problem is simply that you have used a ‘,’ instead of a ‘.’ on the following line.
if (randomNumber <= 0,5)
Should instead be:
if(random <= 0.5f)