void OnTriggerExit2D(Collider2D trig) { if (trig.name == "WizardTrigger") { wizardparent = trig.transform.parent.gameObject; wizardbody = wizardparent.transform.GetChild(1).gameObject; WizardEnemyScript wizardscript = wizardbody.GetComponent <WizardEnemyScript>(); wizardscript.playerisinrange = false; wizardscript.needtoresetposition = true; } }
void OnTriggerStay2D(Collider2D trig) { if (trig.name == "WizardTrigger") { wizardparent = trig.transform.parent.gameObject; wizardbody = wizardparent.transform.GetChild(1).gameObject; WizardEnemyScript wizardscript = wizardbody.GetComponent <WizardEnemyScript>(); wizardscript.playerisinrange = true; if (wizardscript.needtoswap == true) { transform.position = wizardscript.wizardposition; wizardscript.needtoswap = false; } } }