AddForce Collision Detection?

I have coded a weapon system that instantiates a bullet prefab, all of the code for movement/detection is on the bullet, the bullet adds 1000 force moving forward (closest to how I want it to look). If I don’t use AddForce and use transform.Translate instead collision is perfect, however it doesn’t look how I want it to and doesn’t get a drop effect either.

The bullet basically checks if the collider it’s hit has a tag of “Target”, if it does then delete itself and the object.

I have a rigidBody & capsule collider that is set to trigger on the bullet. On the target I have the tag set to “Target” and a capsule collider with trigger off. There is a detection there as it works 3/10 times but I need it to work every time, I’ve tried all of the Collision Detection options on the bullets Rigid Body too.

void Start() {
		StartCoroutine ("Delete");
	}

	void Update() {
		GetComponent<Rigidbody> ().AddForce (transform.forward * 1000f);
	}

	void OnTriggerEnter(Collider other) {
		if (other.tag == "Target") {
			Debug.Log("HIT!");
			Destroy(gameObject);
			PhotonNetwork.Destroy(other.gameObject);

			//Setup PhotonNetwork.room.CustomProperties to handle sending Target Death
		}
	}

	IEnumerator Delete() {
		yield return new WaitForSeconds (10);
		Destroy (gameObject);
	}

I would try to use pooling system instead of instantiating (it’s a good thing to do anyway) but with a tiny difference. I discovered recently that even enabling a collider on the fly was sometimes making the collision not to work very good, like UNITY need a time to calculate newly activated colliders. So instead I modify layers on the run and it works like a charm.

So the big lines:

-Watch this if you don’t know about pooling: https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/object-pooling

-(the most difficult part) Modify it so it won’t deactivate the GameObject but put it somewhere where you can’t see them. In order to do it, you need a list of bool to track if the GameObject pulled(i.e. the bullet) is in use. Then check if the bullet is in use before return it. Here is the script I would use in C#.

public class PoolerActivated : MonoBehaviour
{
    public static PoolerActivated current;
    public GameObject pooledObject; //you will put the bullet here
    public int pooledAmount; //numbers of bullet instantiated 
    List<bool> isActive;
    Vector3 pool; //where you want your bullets to "rest"
    List<GameObject> pooledObjects;
    
    void Awake()
    {
        current= this;
        pool = GameObject.FindGameObjectWithTag("Pool").transform.position; //or set it manually 

        pooledObjects = new List<GameObject>();
        isActive = new List<bool>();

        for (int i=0; i<pooledAmount; i++)
        {
            GameObject obj = (GameObject)Instantiate(pooledObject);
                pooledObjects.Add(obj);
                isActive.Add(false);
                obj.transform.position=pool;
         }
    }

    public GameObject GetPooledObject()
    {
        for (int i=0; i< pooledObjects.Count; i++)
        {
            try
            {
                if (!isActive*)*

{
isActive*=true;*
return pooledObjects*;*
}
}
catch {print(“Error trying to get pooled object”;}
}
// if all the bullet are used it will create a new one
GameObject obj = (GameObject)Instantiate(pooledObject);
pooledObjects.Add(obj);
isActive.Add(true);
return obj;
}
return null;
}

public void Deactivate(GameObject obj)
{
for(int i=0; j< pooledObjects.Count; i++)
if(pooledObjects == obj)
{
isActive*=false;*
obj.transform.position=pool; //put in the pool
break;
}
}
}
}

-Your bullet object need to have a layer that doesn’t collide with anything. I found it usefull to have a layer for that and personnaly use the default layer as I monitor all my collisions rules with the physics options (nice for performance to avoid unnecessary collisions). It also need to have the collision detection mode to continuous dynamic.
-In your gun script change the layer of the bullet after calling it. Call your bullet like this:
GameObject bullet = PoolerActivated.current.GetPulledObject();
//do all the positionning and the addforce here
bullet.layer = someIntLayersForBullets;
-In the bullet script change the layer of the bullet after the collision to the one that don’t collide with anything. Also say to the pool in no longer in use like this:
gameObject.layer=someIntLayerWithNoCollision;
PoolerActivated.current.Deactivate(gameObject);
Hoping this would solve your issue. I think pooling is a good way to use bullets anyway.
_*Edit: I just noticed that you use addforce in an update. You should use it once on instantiation instead and with ForceMode.Impulse : http://docs.unity3d.com/ScriptReference/ForceMode.html*_