Destroying objects when collisions happen is not consistent.
This is with 2D physics.
I have a bullet object with the following script attached:
using UnityEngine;
using System.Collections;
public class Bullet2D : MonoBehaviour {
void OnCollisionEnter2D(Collision2D coll){
Destroy (gameObject);
}
}
It also has a BoxColider2D and a Rigidbody2D When it colides with the enemy (which also has a BoxColider2D and a Rigidbody2D), the bullet disapears and nothing else happens.
However, when i have the enemy's bullets hit the player (the script is the same one, the components are the same in both the enemy bullet and the player) the bullet still gets destroyed as expected, but now, the player gets pushed back as well.
What i was expecting was either that in both cases the characted gets pushed back from the impact, or that both stay put without moving.
As i said, all is the same between the playerCharacter and the enemyCharacter, and between the playerBullet and the enemyBullet. The only diference is that each of the four objects is in its own layer, and the layers are set up so the the playerprojectiles cannot interact with the player or other playerprojectiles, and the enemy projectiles cannot interact with the enemy or other enemyprojectiles.