- Home /
collission not triggered when i touch object..
i have 1 First Person Controller as a player and created 1 cube with as enemy.
Enemy has rigidbody to assign gravity to it and it moving on 1 platform which is made from cube.
collision detect script is attached with enemy. when enemy touch player method triggered successfully. but when i touch enemy method is not called.
@FastTrack Could you post the Collision script?
void OnCollisionEnter(Collision collision) {
Collider other=collision.collider;
Debug.Log(string.Format("OnCollisionEnter tag={0}",other.tag));
//
if(other.gameObject.tag=="Player")
{
Debug.Log("Player1 Touched");
}
}
I dont know JavaScript very well so sorry if this doesn't work but you Could true this:
function OnTriggerEnter(other: Collider){
if (other.tag == "Player"){
Debug.Log("Player1 Touched");
}
}
This might fix it but if it doesnt post a reply and I'll try something else.
OnCollisionEnter function it self not getting called when player touched the cube!!!
Does the cube have a Rigidbody attached? @FastTrack
Answer by FastTrack · Jan 01, 2014 at 04:17 PM
yo yo i found the answer. as I have used firstpersoncontroller i have to implement below method to find collision
void OnControllerColliderHit(ControllerColliderHit collision)
{
Debug.Log(string.Format("object tag={0}",collision.collider.gameObject.tag));
}
Thank you all for your help. unity link that helped me.
http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnControllerColliderHit.html