Question by 
               Karan_makvana · May 22, 2017 at 03:32 PM · 
                raycastbulletraycasthit  
              
 
              Raycast not detecting hit with collider
I am try to make a 2D game in which lasers collide with circular arena and reflect back in ricochet manner. I have written this code in update function. I am using raycast to reflect bullet in ray's direction.But i cannot seem to get hit with the collider.After collion with arena bullet remains at its place.
here's the code
void Update () {
     transform.Translate (Vector3.right*Time.deltaTime*speed);
     Ray ray = new Ray (transform.position,transform.right);
     Debug.DrawLine (transform.position, transform.position + transform.right, Color.green);
     RaycastHit hit;
     if (Physics.Raycast (ray,out hit,Time.deltaTime*speed + 0.1f)) {
         Debug.Log ("detected hit");
         Vector3 reflectdir = Vector3.Reflect (ray.direction,hit.normal);
         float rot = Mathf.Atan2 (reflectdir.y,reflectdir.x) * Mathf.Rad2Deg;
         transform.eulerAngles = new Vector3 (0,0,rot);
     
     }
 }
 
              
               Comment
              
 
               
              Your answer