- Home /
Random Drops
OK, So i how would i go about making a random number drop for a palm tree? I want it so when i chop down the palm tree (a script i already have), it drops maybe 0-2 coconuts. But right now the script makes it always drops one, any suggestions?
Answer by Statement · Mar 07, 2013 at 12:52 AM
You could use int num = Random.Range(0, 3);
It would make num 0, 1 or 2.
How could i link the two? heres the part of the script that drops the Coconut.
var Coconut = Instantiate (Coconut, spawnPoint.position, Quaternion.identity);
Coconut.rigidbody.AddForce(transform.forward * 0 );
int count = Random.Range(0, 3);
for (int i = 0; i < count; ++i) {
var Coconut = Instantiate (Coconut, spawnPoint.position, Quaternion.identity);
Coconut.rigidbody.AddForce(transform.forward * 0 );
}
But they would all be created in the same location..
it gives me a bunch of errors. should i post my whole script?
Your answer
Follow this Question
Related Questions
removing an int from a Random.Range 1 Answer
Procedural Generation... 2 Answers
How do I animate my enemy randomly with time? 1 Answer
Spawn Script not working on Iphone. 1 Answer
Deactivate the children 2 Answers