I want to spawn objects probabilistically.
I spawn three kinds of objects. but, it's always same Probability. I want 1Object is 50%, 2Object is 40%, 3Object is 10%.
I received this answer from my previous question.
 float ranNum = Random.Range(0,1);
 if(ranNum <= 0.1f) { //10%
 }
 else if(ranNum <= 0.3f) { //0.3f - 0.1f => 20%
 }
 else { 
 }
I'm use Instantiate code.
 if (timer <= 0) {
 Vector3 enemyPos = new Vector3 (Random.Range (-1.8f, 1.8f), transform.position.y,             
 transform.position.z);
 enemyNo = Random.Range (0, 3);
 Instantiate (enemys [enemyNo], enemyPos, transform.rotation);
     timer = delayTimer;
 }
How do I write this code with that code?
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                