It has 3 functions. Attack 1, Attack 2 and Attack 3.
I want it so there’s a 40% chance for Attack 1, 40*%* chance for Attack 2 and 20% chance for Attack 3.
I’ve been looking into different methods on how to achieve this with enums and switches, but there’s something lacking like the % chance in say, Random.Range.
So, I’m clearly missing something. Got any idea on how to achieve this?
Random.Range(0.0f, 1.0f) should give you a value between 0 and 1
Now you can achieve 40% by checking if the value is below 0.4
if not, you can check if it’s below 0.8. Because we already checked if it’s below 0.4, we don’t need to here
and what’s left is the rest of the 100%, 0.8-1
if random < 0.4 then
...
else if random < 0.8 then
...
else
...
endif