// Update is called once per frame void Update() { shoot.loop = false; int layerMask = 1 << 9; Debug.DrawRay(camera.transform.position, camera.transform.forward, Color.red); if (Input.GetButtonDown("Fire1") && FindObjectOfType <PlayerMains>().Ammo > 0) { FindObjectOfType <PlayerMains>().ammo_cap -= 1; shoot.Play();; // Debug.Log(FindObjectOfType<PlayerMains>().Ammo); if (Physics.Raycast(camera.transform.position, camera.transform.forward, out hit, range, layerMask)) { EnemyMain target = hit.transform.GetComponent <EnemyMain>(); if (target != null) { target.TakeDamage(damage); } Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal)); // Debug.Log(hit.collider.name); } } }