Question by 
               sebastianhausken · Apr 03, 2019 at 08:14 AM · 
                collisionphysicsbulletdetection  
              
 
              Cant get a bullet to detect collision.
I have tried OnCollisionEnter, OnTriggerEnter and raycast but i cant get anything to work.
What i want it to do is to play a little animation and remove the clone but as i said in the title i cant seem to get it to detect collision.
Bullet when cloned:
 public float speed = 10f;
 public Rigidbody rb;
 void Start ()
 {
     rb.velocity = transform.forward * speed;
 }
 
               }
Cloning bullet:
 void Update ()
     {
         if (Input.GetButton ("BulletFire")&& Time.time > NextFire)
         {
             NextFire = Time.time + FireRate;
             GameObject clone = Instantiate (Bullet, BulletSpawn.position, BulletSpawn.rotation) as GameObject;
         }
 
               Here is one thing i tried:
         if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity, layerMask))
         {
             Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * hit.distance, Color.yellow);
             Debug.Log("Did Hit");
         }
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Checking for collisions 1 Answer
I need the functionality of both OnTriggerEnter and OnCollisionEnter in unity 1 Answer
How to make gridbased movement while also using collision? 0 Answers
Is there a way to limit animation on collision? 1 Answer
Why Does Bounciness Affects Rigidbody Velocity? (SOLVED) 0 Answers