I’ve been looking for a way to set up an item spawn script, which instantiates a given item at a certain percentage. I also want to have the chance to drop nothing. Overall, the item spawn system should work as such:
Each item should have a specificed probability of spawning.
The system should give the chance to spawn nothing at all.
Given the amount of health the player has, a healing item should have a chance to spawn.
For example, given three items (one for healing, one for attack increase, one for defense increase), I should be able to give a certain percentage of spawning in one of these items. If the player has low health, the probability of spawning a healing item should increase; whereas, the probability should decrease when the player has full health.
If anyone has any ideas for creating an item, I would be pleased to listen.
Generate a random number betwin 0 to 1000, and then you can do that if that number is betwin 1 to 20 than instantiate object 1, if it is betwin 20 to 30 instantiate a secon object, then you can have diffrent probabilitis for each object and leave some numbers to do nothing
(The numbers i gave you are just an example, you can use any number to get any probability)