void Update() { if (shot) { Transform cam = Camera.main.transform; Debug.DrawLine(cam.position, cam.position + Camera.main.transform.forward * 20f); } if (Input.GetButtonDown("Fire1") && Time.time > nextFire && !gunAim.GetIsOutOfBounds()) { nextFire = Time.time + fireRate; muzzleFlash.Play(); cartridgeEjection.Play(); anim.SetTrigger("Fire"); shot = true; Transform cam = Camera.main.transform; RaycastHit hit; if (Physics.Raycast(cam.position, cam.forward, out hit, weaponRange)) { HandleHit(hit); Debug.Log("Coe funciona ai na moral"); DuckBehavior duckBehavior = hit.collider.gameObject.GetComponent <DuckBehavior>(); duckBehavior.Hit(); } } }
void Update() { if (Input.GetButtonDown("Fire1") && Time.time > nextFire && !gunAim.GetIsOutOfBounds()) { if (Time.time - nextFire < 0.1f) { consecutive_shots += 1; } else { consecutive_shots = 0; } nextFire = Time.time + fireRate; muzzleFlash.Play(); cartridgeEjection.Play(); anim.SetTrigger("Fire"); Vector3 rayOrigin = gunEnd.position; RaycastHit hit; if (Physics.Raycast(rayOrigin, gunEnd.forward, out hit, weaponRange)) { HandleHit(hit); } } }
void Update() { if (Input.GetMouseButtonDown(0) && Time.time > nextFire && !gunAim.GetIsOutOfBounds()) { nextFire = Time.time + fireRate; muzzleFlash.Play(); cartridgeEjection.Play(); anim.SetTrigger("Fire"); Vector3 rayOrigin = gunEnd.position; RaycastHit hit; if (Physics.Raycast(rayOrigin, gunEnd.forward, out hit, weaponRange)) { HandleHit(hit); } } }