Hi.
I have a following script which changes “damagePerShot, timeBetweenBullets and spread” variables when called:
public void SetWeapon(int damage, float tbb, float newSpread)
{
damagePerShot = damage;
timeBetweenBullets = tbb;
spread = newSpread;
Debug.Log(damagePerShot);
}
When I call the function inside the script (in start function for example) it works just fine, but when it is called from another script, it runs the script but it doesn’t change the values. All the variables are private. Any ideas?
Thanks!
Oh, and earlier when I had a variable: “ammoCount” in the same script. I could pickup ammo from the ground and it was added to the variable. The weird part was when I quit the game, the ammoCount didn’t reset?! If I picked up 300 ammo on the first try and quit the game, the value was the same at the beginning of the second try?!
I couldn’t find a solution for this problem so I decided to make different kind of weapon system and then ran into this problem with the SetWeapon function.
Since I can’t find any solutions for this, I’m assuming my Unity project is broken. I did have to install my Windows and all my programs again (including Unity) a month ago so I guess it’s possible that it messed up the project somehow? I have tried to Reimport the Assets again etc. but it doesn’t help.
So all I can think of is starting the project again from a scratch…