I have a GameObject that is supposed to set a boolean on its animator to true once a trigger is called. Thing is, I debugged it with print() and found that it was never called? Both the objects have 3D colliders, and one of them has a rigidbody. I have the object that needs to be collided with set to trigger. I triple-checked that my trigger Gameobject’s tag is spelled correctly as well. I am lost on what I could be missing. Please help? Thanks.
Here is the code for the trigger.
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == ("PlayerAttack"))
{
health = health - 40;
print(health.ToString());
if(health > 0)
{
Anim.Play("GhostLightHit");
Anim.Play("GhostIdle");
}
else if(other.gameObject.tag == ("EnemyTarget"))// The script part that isn't working
{
print("Collided");
Anim.SetBool(Attacking, true);
Anim.SetBool(canMove, false);
Audio.clip = otherClip[Random.Range(0,otherClip.Length)];
}
else
{
Instantiate(GhostDead, transform.position, transform.rotation);
Destroy(gameObject);
}
}
}