So when I make changes to a certain script (The weapon) It does not change ingame, however, when I make a change to the character value of health ( A different script) it does infact change ingame? I don’t understand why.
So I have the damage set to 25, I had it before set to min 10 max 20, but now it’s set to 25. The character has 100 health, in theory, shooting the player 4 times should kill him right? No, that’s not the case, obviously it’s still doing the original 10-20 damage, I don’t know why? I changed the health value and tested it, I changed health to 1 and one shot kill so that worked, but why not the weapon script?
I’ve literally been looking through this for over an hour now trying to find the problem, I’d be very appreciative if something with more experience could help me find it.
Mark the DamageMin and DamageMax as private and it will be forced to an internal Unity Serialization even though by default the public variables are made private by serialization.
Once you do this , you can enable Debug Mode by clicking next to the lock icon.
And then you can see DamageMin and DamageMax in the inspector and tweak their values which i think should reflect changes.
@Gahou, I recommend for you to look up some scripting tuts before asking specific questions like this. It’ll be a lot faster and less spammy. Anyways, since you asked, I’ll do my best to answer your questions.
For the main question: If a variable is public, it gets serialized and shown/modified in the inspector. The value is then based on the inspector’s value for the variable and not the default value you set. To fix this, you can either make the variables private or set them to your desired value.
For the error: In C#, every line of code has to do something. For example, you have an apple called Apple. You can create Apple. You can set the color of Apple to red. You can take a bite out of Apple. etc…
You can’t, however, Apple. There needs to be a verb somewhere in there. In that line with spreadTemp, you’re just stating spreadTemp but not doing anything. That’s what the error means. To fix this, you can remove the line of code or add a verb in there.