Hi im working in a 2dtile based game and im new in unity.
The question is, i have gameobject Enemy with enemy.cs script also i have the prefab gameobject deathSpell with a spell.cs script.
in the top of Enemy class i have this
public GameObject deathSpell; //then i drag the deathSpell to here in inspector
Also i have a function in Enemy script to send a spell to player, like this.
GameObject instance = Instantiate(deathSpell, orgPos, Quaternion.identity) as GameObject;
deathSpell.GetComponent<Spell>().hitTarget(orgPos, tgPos);
Destroy(instance, 3f);
So in the function hitTarget inside Spell class i make this
spellOrg = origemAtk;
spellDest = target;
atack = true;
then in update method of SpellClass i check if atack is true then
trace a route to player and hit.
The problem is, the variables of the Spell Class are not being reset even after Destroy command. So if i execute this function
deathSpell.GetComponent<Spell>().hitTarget(orgPos, tgPos);
in the second time not work properly, is looking unity keep script in cache something like this, even if i stop the game and run again.