hi,im new to scripting and i have this slight problem where the console.Debug… repeats it self i.e Health20%
but then another one that says Health0%
any help will be appreciated,thanks
Look in your script for any Debug.Log() or print() statements.
We would have to see the script to help out more.
You probably have more than one script of the same type in your scene. If you type the script name in the Hierarchy search field, it will show you all components, with the script attached to. Sound like you might have accidentally duplicated it or something.
wow u guys replied really quick.
public int currentHealth;
public int currentAmmo;
private int MaxAmmo = 32;
// Use this for initialization
void Start()
{
if (currentHealth <= 100)
{
Debug.Log(string.Format("Health:{0}%", currentHealth));
}
if (currentAmmo>= MaxAmmo)
{
Debug.Log("Max Ammo");
}
if (currentAmmo < MaxAmmo)
{
Debug.Log(string.Format("Ammo:{0}/{1}", currentAmmo, MaxAmmo));
}
o crap i just realized i’ve got 2 of them scripts ,similar script on two different objects
2 Likes