What should be called instead of oncollisionenter2d?

What should be called instead of oncollisionenter2d?

OncollisionEnter2D should be OnCollisionEnter2D I believe. Add colliders to both of them and use OnTriggerEnter () function instead of OnCollisionEnter (). Unity script reference: http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnTriggerEnter.html

Why is unity oncollisionenter2d not calling game?

By adding the appropriate collider component, the sprite will also respond to collisions with other sprites. You’ve not marked your moving rigidbody with the right collision detection method. You need continious dynamic rather than discrete if you are moving your object with speed.

How to collide two objects in rigidbody2d?

First of all, here is some relevant information: I have two objects that could collide, let’s call one Bullet and one Enemy. Both Bullet and Enemy have RigidBody2D components attached to them, as well as the following method in an attached script: void OnCollisionEnter2D (Collision2D collision) { print (“Hit!”);

Is there a collision response to a contact?

Again though, a contact doesn’t mean a collision response though. For instance, triggers produce contacts but there’s no collision response. What you will get with this option are callbacks and the ability to use GetContacts .

Why is C #-oncollisionenter not called in Unity?

You need to make sure that the collision matrix (Edit->Project Settings->Physics) does not exclude collisions between the layers that your objects belong to. You also need to make sure that the other object has : collider, rigidbody and that the object itself or either of these components are not disabled.

Do you need rigidbody for collision detection in Unity?

Even if your colliders as marked as trigger, at least one of the 2 GameObject involved must have a RigidBody attached. Collision between GameObject can be selective enabled depending on the layer the GameObject ‘s belong to. Have a look at Layer-Based Collision Detection.