This question was
closed Jun 18, 2016 at 07:49 AM by
Hellium for the following reason:
Duplicate Question
Problems with triggerEnter()
Hi. I want My game object to enter trigger object and t change his target to the next trigger point.But when he enters the trigger it does nothing.
using UnityEngine; using System.Collections;
public class MOvement : MonoBehaviour { public GameObject target;
void Start () {
}
void Update ()
{
transform.LookAt(target.transform);
transform.Translate(0f,0f,1f);
}
void OnTriggerEnter(Collider col)
{
if(col.gameObject.tag == "PathPoint" )
{
Debug.Log("gg");
}
}
}
object target already has tag "PathPoint",and it's collider is trigger.I don't understand why it doesn't work
Comment
it's not ONCollision enter so it it must work,in same project i used on trigger enter but at other gameobjects it works but with that example it doesn't.What can cause such problems?
https://docs.unity3d.com/ScriptReference/$$anonymous$$onoBehaviour.OnTriggerEnter.html
Notes: Trigger events are only sent if one of the colliders also has a rigidbody attached.