public virtual void Fire(Vector3 direction) { Invoke(nameof(End), Life); transform.LookAt(transform.position + direction); Velocity = Speed * direction; OnFired?.Invoke(this, direction); }
void triggerFire() { var force = -controller.target.dir.normalized * bulletVelocity; var nObj = GameObject.Instantiate(bullet); if (fireStart == null) { nObj.transform.position = this.transform.position; nObj.transform.rotation = this.transform.rotation; } else { nObj.transform.position = fireStart.transform.position; nObj.transform.rotation = fireStart.transform.rotation; } nObj.GetComponent <Rigidbody2D>().AddForce(force, ForceMode2D.Impulse); audioSource.PlayOneShot(fireSound); OnFired?.Invoke(this, new EventArgs()); }
public void EventFired() { OnFired?.Invoke(); }