- Home /
 
 
               Question by 
               TwilightZone13 · May 15, 2021 at 10:12 PM · 
                2d gameshootingbulletsgame view  
              
 
              Why will the bullets sometimes not show up in the game view when the player shoots?
When I press the shoot button, which I have mapped to space, the bullets sometimes won't appear on the game view but will appear in the scene view. There is nothing in front of the bullets causing them not to appear. I have noticed that this occurs at specific coordinates, (-4.06, -8.15), (2.6, -8.15), (4.5, -8.15), (3.9, .8.15) are some of the rough coordinates that the bullets won't show in the game view. Video of ploblem: https://imgur.com/a/bKM0arz
Bullet script:
 public class Bullet : MonoBehaviour
 {
     public float speed = 20f;
     public Rigidbody2D rb;
 
     // Start is called before the first frame update
     void Start()
     {
         rb.velocity = transform.up * speed;
     }
 
     private void OnTriggerEnter2D(Collider2D collision)
     {
         Debug.Log(collision.name);
         Destroy(gameObject);
     }
 }
 
               Turret script:
 public class Turret : MonoBehaviour
 {
     public Transform firePoint;
     public GameObject bulletPrefab;
 
     // Update is called once per frame
     void Update()
     {
         if (Input.GetButtonDown("Fire1"))
         {
             Shoot();
         }
     }
 
     void Shoot()
     {
         Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
     }
 }
 
              
               Comment
              
 
               
              Your answer