Building an incremental game...

Hey guys, so I am building an incremental game and I am still very new to coding in JS and using Unity, let alone the new version 5. Alright, what you should know to help with this is that the code doesn’t seem to use the correct variable. When the player “Hires a punk” it should increase the total income by their bonus (0.02) but instead it increases the amount by the total amount of punks hired.

Now, instead of posting the coding here as it would be a rather large amount, I am going to post a link to haste bin.

http://hastebin.com/yemiyidewo.js

Please also note, that as I am learning, the code may not be up to standards hahaha.

EDIT: Forgot to mention that there isn’t anything onscreen just yet so you will have to add this script to something (I am using the main camera currently) and then watch the variables in the inspector panel if you are wanting to verify the code… sorry

Input.GetKey > Input.GetKeyDown
So it only runs when key is pressed, otherwise it will run 10 times while your key is held down for that split second.

Thats really the only thing I can see wrong, try it out.

Alright, so I did your change and now what happens is that it is increased by 0. I did some testing and after changing the number from 0.02 to 0.2 (so I only needed to his this button 5 times to get a whole number) it still stays at zero, then I started to debug log it… comes up “0” looked some more and saw that it was an int, changed to a float, but still “0” in the debug.log.

I just want to clarify something… I read somewhere that an int isn’t used when wanting to carry over a decimal point, is this correct? should I keep it a float?

Also, thanks for the help

Yes I am double posting, but it’s because this was solved…

The issue was within the constructor and the arrangement of the variables… if I put the float (_increase) first and then the int (_cost) then it works… or if I made both floats it works…

Code Link: http: //hastebin.com/senipucapi.vala