i have “bullet” object that is spawn when user press fire button
void Update () {
if (fireRate == 0) {
if(Input.GetButtonDown("Fire1")){
Instantiate (BulletTrailPrefab, firePoint.position, firePoint.rotation);
}
}
}
bullet prefab has BoxCollider2D and script that make its move, in that script i want to detect collision with any other object
// Update is called once per frame
void Update () {
transform.Translate (Vector3.right * Time.deltaTime * moveSpeed);
Destroy (gameObject, 1);
}
void OnCollisionEnter2D(Collision2D coll) {
Debug.Log (coll.gameObject.name+" was hit");
}
however when i shoot test object - it also have boxCollider2D - OnCollisionEnter2D not been call