- Home /
OnCollisionEnter not called on Unity4.3 for 2D.
Hi, I have two 2D object, one is use to throw by catapult and then it hit other 2D object. Both have collider and Rigidbody both have unchecked isKinetic and isTrigger. When they collide with each other then OnCollisionEnter method doesn't call and script is attached to that object which is thrown by catapult. Kindly if any one face this problem help me on this. Thanks in advance.
Answer by clunk47 · Nov 26, 2013 at 07:15 AM
2D physics require 2D colliders. Replace Rigidbody components with Rigidbody2D, Colliders with 2D colliders. Replace OnCollisionEnter(Collider col) with OnCollisionEnter2D(Collider2D col).
Have a look HERE for further help.
Thanks bro, Now getting bit issue when its collide I want to run animation onto second object, to show like it blast. I attached animation with that object and when I run code it gets crash. Here is what I am doing. declare string on top and call on collision. string blastAnim = "BlastAnim";
void OnCollisionEnter2D(Collision2D col){ Debug.Log("Collision Enter............."); animation.Play(blastAnim);
}
What do you mean when it crashes?? Do you get an Error? Do you get your Debug.Log message?
I mean when this line of code run animation.Play(blastAnim); and it error is "EXC_BAD_ACCESS (code =1, address=0x0)".
Your answer
