- Home /
 
               Question by 
               ruff19ruff · Jun 13, 2020 at 12:39 AM · 
                collision3dtriggerbulletdestroygameobject  
              
 
              How to destroy bullet upon colliding with another object instead of bouncing off of it
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Bullet : MonoBehaviour { public float lifetime = 10f; public float speed = 1f;
 // Start is called before the first frame update
 void Start()
 {
     Destroy(this.gameObject, 3.0f);
 }
 // Update is called once per frame
 void Update()
 {
     transform.Translate(Vector3.forward * speed * Time.deltaTime);
     Destroy(this.gameObject, lifetime);
 }
 private void OnTriggerEnter()
 {
     Destroy(this.gameObject);
     Debug.Log("You got shot! GAME OVER");
 }
} —————- Thank you!
               Comment
              
 
               
              Answer by unity_vyvb-GSfngIBrQ · Jun 13, 2020 at 12:42 AM
what is the problem right now ? the bullet is not destroy ?
Answer by ruff19ruff · Jun 13, 2020 at 03:14 AM
@ unity_vyvb-GSfngIBrQ Yeah, I play my game and the bullet collides and doesn’t go away until the timer kills it :(
Answer by davidmaamoaix · Jun 13, 2020 at 05:01 AM
Does your bullet (and the target) have an appropriate collision box?
Your answer
 
 
             Follow this Question
Related Questions
My trigger is called twice 1 Answer
Collision not working... [Solved (b/c I'm dumb)] 1 Answer
Predict Collision 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                