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.
1 Answer
1
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
@FastTrack Could you post the Collision script?
– MattTheProgrammervoid 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"); } }
– FastTrackI 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.
– MattTheProgrammerOnCollisionEnter function it self not getting called when player touched the cube!!!
– FastTrackDoes the cube have a Rigidbody attached? @FastTrack
– MattTheProgrammer