Image appearing after clicking a button

So I’ve done about 2 days worth about of googling so I apologize if this has been answered somewhere else and I couldn’t find it. I will also say that I am new to Unity and although I have coding experience with Java, c is still somewhat foreign to me, so a through explanation of any scripts would be appreciated.

I currently have a 2D game where I have a background, a UI image of a robot, and UI image of armor. The buttons say light, medium, and heavy armor and I would like to have the game work so If I press the light button, the image for light armor appears over the image of the robot. Likewise for the medium and Heavy buttons. I can’t seem to figure out how to accomplish this.

Hey Wolgy88,

I havn’t worked too much on 2d games and sprites but I would imagine that you could save a static public Integer on the robot which when assigned to 0 means the robot has no armor and when it is equal to 1, 2, or 3 then the robot is wearing light, medium, or heavy armor.

After the Integer is setup then I would change the image of the robot to a new made up image of the robot with these armor’s or change the position of the armor to be the same as the robot’s and possibly become a child of the robot’s.

As I said I havn’t worked much with 2d games but I believe that this should work, also using static public variables can be a bit troublesome I believe especially when you use many but as a temporary fix or even just a once off use should be fine.

If you provided further information like whether it is sprites or gameobjects you use for the robot and armor etc. then I am more then happy to provide further assistance :slight_smile:

I hope this helps.

Kind Regards,

IHackedDeath.