Collisions between two rigidbody's and scripting collisions problem

Hello everybody! Im having trouble and I would really appreciate the help.

I have an enemy character with a gun shooting bullets (bullets with rigidbody to apply force going 20f) and I want the bullets to hit my character (also with a rigidbody) and then destroy the bullets. I have this script attached to the bullet prefab:

using UnityEngine;
using System.Collections;

public class BulletHit : MonoBehaviour
    private GameObject bullet;
    // Use this for initialization
    void Start()


    void OntriggerEnter(Collider other)
        if (other.gameObject.CompareTag("BlueCube"))
           print("Bullet hit!");

But it does not seem to register at all and the bullets do just bounce of my character. is it different because this script is attached to a prefab and not to a normal gameObject? I have a similar script on an other enemy that does not have a rigid body. Is the problem that both objects have a rigid body?

As I understand it, only one object of the two colliding can have a rigid body for functions like OnTriggerEnter and OnCollisionEnter. But what if I would want to make bullets that hit both static objects without a rigidbody and moving objects with a rigid body? That has to be possible, right? I would really appriciate it if someone could explain the exact interaction of rigidbody’s and collision-detection to me.

Thanks in advance!

Bro actually you have misspelled the collision function name … it is OnTriggerEnter and not OntriggerEnter that letter T should be capital

Physics in unity run at specified interval, which is I believe 0.02 seconds by default. Now think what happens when a bullet gets shot at very high speed. In one “frame” of physics, the bullet is in front off the wall, in the next one, it is behind it (flew through). Simply the physics engine does not think that you hit anything.

Now to the solutions:

  1. Use Raycast. Using raycast you can have bullets behave like in Counter Strike. These are not physical bullets, instead it is just a ray which gets shot at a specified direction. You can use RaycastHit to do the checks for what the raycast hit and you also can set the maximum distance of the ray. Here is a code snippet from my scripts:
    RaycastHit hit;

Physics.Raycast (transform.position, transform.forward, out hit)) {

Do the stuff here

2. DontGoThroughThings. That is if you really need physics bullets. Note, I have not tried this, but it is what you might want.
3. Collision detection mode can be used for quickly making a rigidbody not pass through things. You would need to use Continuous dynamic mode which makes bullets not pass through both static and dynamic objects. Do not use this everywhere. Over 100 objects with this setting can bring the performance down of the game, especially if no physx card is present.