Okay, sorry for poor title, I don’t know how I would title this. But okay, I have two scripts, but I’m only gonna include some of them, but if you need more of a certain script, feel free to ask. I’m gonna try wording this the best I can because I have a mild form of autism and I have my own way of speaking, so if you also need me to explain with what I mean, feel free to ask as well.
Okay, so I have a game, where if you click the warrior icon, it deducts money and it instantiates a prefab,
At the same time, every so often, on the other side of the map there is a enemy that is instantiated.
I have a part of a script that is attached to the enemy, and the script is like this :
private void OnTriggerEnter(Collider other)
{//on trigger enter..
if (other.tag == "Weapon") //if the tag of the collider is "Weapon"
{
Health--; //deduct health
}
And that works.
However, below that section of the script, it says this :
if(other.tag == "Player")
{
Health1.DeductHealth();
}
Now in the Health1 Script, more specifically “DeductHealth” it is this :
public void DeductHealth()
{
Health--;
print("Health - " + Health);
}
Now the issue I am having, is instead of removing health from the Warrior that was bought, it removes health from the original prefab, So I was wondering, am I doing something wrong? Is there no way to do this? Or…?
Thanks for reading!