void Attack() { time += Time.deltaTime; if (time % 4 < 1f && _primary != null) { _primary.FireButtonDown(target.transform.position); pFire = true; } else if (pFire) { _primary.FireButtonUp(); pFire = false; } if (time % 4 > 2f && time % 4 < 3f && _secondary != null) { _secondary.FireButtonDown(target.transform.position); sFire = true; } else if (sFire) { _secondary.FireButtonUp(); sFire = false; } targetLastSeen = target.transform.position; }
// Update is called once per frame void FixedUpdate() { // Primary weapon if (Input.GetAxisRaw("Fire1") > 0f && _primary != null) { Vector3?target = MousePointOnFloor(); if (target.HasValue) { primaryUp = true; _primary.FireButtonDown(target.Value); } } else if (primaryUp && _primary != null) { primaryUp = false; _primary.FireButtonUp(); } // Secondary weapon if (Input.GetAxisRaw("Fire2") > 0f && _secondary != null) { Vector3?target = MousePointOnFloor(); if (target.HasValue) { secondaryUp = true; _secondary.FireButtonDown(target.Value); } } else if (secondaryUp && _secondary != null) { secondaryUp = false; _secondary.FireButtonUp(); } }