Help with Buttons and Combinations

Hello guys, I’m currently working on a project that consist in “brewing potions”.

Here is the idea: We have four elements (fire, water, air and earth), we need 3 of this 4 elements to brew a potion, so the player must make a combination of 3 elements, no matter what order to make a potion.

But here is the deal, to make a good visual effect we want to make that every element button pressed, will add a visual effect on the potion, if the player press fire (for example) the potion will be 1/3 filled with a red liquid, then if he press earth button it will be 1/3 red liquid and 1/3 brown liquid. If you got the idea we will need to make 19 combinations and to script it will be quite frustrating.

Should I use If in every statement like:

if (firePressed )
//Change the potion image to be the one with 1/3 fileld with red liquid.

if (firePressed && earthPressed)
//change the potion image to be the one with 1/3 filled with red liquid 1/3 filled with brown liquid

and so on…

than i repeat this one million times or is there another way to do this? (I know there is, I just don’t know to do it!)

thanks in advance, happy coding.

I am not sure to understand but you need to script it. And you can use UI Image fill to fill at a value. Instead of us many sprite.

If you have 4 images that are bottled shaped and colored as needed, you can use the fill setting on the images and layer them so that as you add the potion, you move the colored image above each other on the hierarchy.

So if your first color is red, then you just “fill” the image to about 1/3rd. Then brown is next, move it up above red in the hierarchy and then “fill” the brown to 2/3. The red will render in front of the brown, thus making it look like you just added brown on top of red. Then of course your last color will be above brown. You’ll just need to move the colors around an animate the fill (a tweening engine can handle this just fine).

1 Like

soooo, is it more like this?

2 Likes