- Home /
Question by
MrSteve1 · Mar 18, 2013 at 01:33 PM ·
collidertriggerontriggerentertarget
OnTriggerEnter
Hey all,
This is such a noob question, I have used this code before I even copied it from another project I was working on.
var target : Transform;
function Start () {
}
function Update () {
}
function OnTriggerEnter (trig : Collider){
if(trig.gameObject.tag == "enemy"){
Debug.Log("Detected!");
}
}
It's not rocket science is it? But this is attached to a sphere with a trigger, and I have another object Tagged enemy. But it simply will not Debug.
This is probably a school boy error but I can't make it work. please help!
Steve
Comment
Does enemy have a rigidbody? Only rigidbodies will "trigger" a trigger collider.
Answer by PAHeartBeat · Mar 18, 2013 at 03:37 PM
Hi MrSteave1 Collision or Trigger detect when only one of the object have rigid-body, so please add rigid-body component any of the one game object....
thanks fafase to correct my mistake, my knowledge inEnglish is not good