I’m using a script to trigger a collider, and another one to trigger a different one. One makes it so that when you enter, an enemy runs towards you. The other script makes it so that when he gets close, he damages you. Problem is, when I run the game, the first collider makes him run, and the second makes him walk (since they are inside each other.) They are seperate GameObjects, but one is a child of the enemy. How do I make it so that he can still damage you in a certain radius, but not so that the animation change is triggered as well?
Trigger on Enemy(Handles Animations)
void OnTriggerEnter(Collider col){
if(col.gameObject.tag == "Player"){
anim.SetFloat ("Speed", 3f);
anim.SetBool("Running", true);
anim.SetBool("Walking", false);
}
}
void OnTriggerExit(Collider col){
if(col.gameObject.tag == "Player"){
anim.SetFloat ("Speed", 1.5f);
anim.SetBool("Running", false);
anim.SetBool("Walking", true);
}
}
Child of Enemy(Handles Damage)
function OnTriggerEnter (Col : Collider)
{
if(Col.tag == "Player")
{
SanityDamage.currentSanity += scarePercent;
GetComponent.<AudioSource>().PlayOneShot(ScareSound);
hasBeenTriggered = true;
}
}
function OnTriggerExit (Col : Collider)
{
if (Col.tag == "Player")
{
SanityDamage.currentSanity = SanityDamage.currentSanity;
}
}