Hi,
can you please help me with randomly generating coins on random generated terrain? But not generate all the time just from time to time
I will attach picture that shows my game. I am really stuck with that one so any I would appreciate any help. Thanks!
(btw, it is made on iOS/android)
how do you randomly generate your terrain?
Somewhere like update() add a function call to add random coins. In the function pick a random number from 0,999 inclusive. Then if that number returns say less than 100 (== 10%) 500 = 50% etc, add a coin. By varying the number you check against you can make it more or less likely to decide to place a coin. Maybe only make the decision every 1 second or 10 seconds etc so it doesn’t go mad. If you pass the decision then place a coin on your map in a random position. Give it a gravity enabled rigidbody and just place it at the top of the screen. it will fall onto the terrain so this way you don’t need to do any terrain height calcs to know what height to put it. hope this helps.
byte rate = 50;
if(Random.Range(0, 100) > rate) AddCoin();