- Home /
The question is answered, right answer was accepted
The right way to generate levels like Knife Hit or Paint hit game style.
Hi, I m trying to make a game like Knife Hit or Paint Hit. I have done most of the work but I encountered 1 big problem that is generate Objects. So what I want is :
getting a random int number from 3-8 and instantiate obstacles based on that random number. also I need a random number for neededhits to instantiate another obstacle. Here is the gameplay
instantiate first object at start then player has to hit it 4 times after that instantiate another obstacle, this time player needs to hit it 5 times and then instanciate another obstacle until the random number is reached and my level up bool is = true.
I did some research about random.range but I think that is not going to work out. My question is is Random.range the right way?
What would be the best way to get into this. I did not add any code because I don't want to bother anyone. I would be grateful for any kind of help I just want a simple way description.
Answer by bennett_apps · Dec 24, 2018 at 11:13 PM
Using random.range to instantiate a random number of objects is perfectly fine. Is that your question? if so, here's some example code:
int numberObjects = Random.Range (3, 8);
for (var i = 0; i < numberObjects; i++) {
// instantiate your object
}