Download

UE4 - How to set a percentage preference selection in a Switch on Int node?

Hi, i have a switch on integer with 2 options, and a random selection, each option spawns a type of projectile on a tick, every second, the problem is that i canot control how much in percentage may i shoot projectile 1 or 2, and then… it ramdoms select, i wish it is 80% of possibilities of choosing option 1, and 20% of choosing option 2, i have seen the % integer… but no idea how to use it, here is my BP image

Please help with bp pics if possible

Since you have only 2 options, instead of using a Switch, you could do it the way below.

Thanks, but i´m going to add several types of projectiles, some are kind of premium while others are common and i want the common ones to be spawned way more, that´s why i want to understand how to prioritize in a switch selection, but i´m not going to have only 2 choises, actually right now what i´m dong is adding more pins, and connecting them more times to the common projectiles… but i don´t think its ideal because i´m going to have several projectile types and its going to be a crazy connection mess… LOL, that´s why i want to find a way to choose 10% of 1, 30% of 2, 5% of 3, etc.

There is another member on here by the name of ‘Nebula Games’ who also does some videos on youtube for creating custom Nodes. He has a great one which you could use for your situation.
https://youtube.com/watch?v=QDGTtCkIreE
Although he uses it for Random Loot Drops, it would work in your case too. Basically, for you, it would allow you to set up an array of all your projectiles and the percentage rate of each one which you can add and remove from very easily.

So you won’t need any switches etc, you will basically just have 1 node which contains the class of the projectile and it’s percentage to spawn, and an array of the different projectiles you want to use, which you can spawn and then do whatever you want with it.

This is just another option you can look at.