- Home /
Transform Tag Not working!!
Heres my code.. as far as im concerned this is supposed to work :P.. but it won't.. the object this is applied too will detect the object without the if statement.. but even though the object im trying to find has the right tag.. it won't work :( Please help!!
using UnityEngine; using System.Collections;
public class AnimTrigger : MonoBehaviour {
void OnTriggerEnter (Collider col)
{
Animator animator = col.gameObject.GetComponent<Animator>();
if (col.gameObject.tag == "Enemy")
{
animator.SetInteger ("Area", 1);
Debug.Log("yep");
}
}
}
Answer by getyour411 · Aug 01, 2015 at 03:06 AM
Add a debug line immediately after the OnTriggerEnter like
Debug.Log("AnimTrigger hit from :" + col.gameObject.name");
You'll find the 'thing' hitting the trigger is likely some child GOBJ or similar that does not have tag "Enemy"
Your answer
Follow this Question
Related Questions
Transform - GameObject? 1 Answer
Can't Return the Tag of a Child Object 4 Answers
Convert a GameObject to a transform? 1 Answer
Adjusting Rotation of Instantiated Objects 0 Answers
NaN exception when spawning soldiers 1 Answer