Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using UnityEngine;
- public class Weapon : MonoBehaviour
- {
- [SerializeField] private GameObject _buletPrefab;
- [SerializeField] private Transform _launchPivot;
- public event Action OnFire;
- public void Fire()
- {
- var lootAtLaunchPivotRotation = Quaternion.LookRotation(_launchPivot.forward);
- var bulletInstance = Instantiate(_buletPrefab, _launchPivot.position, lootAtLaunchPivotRotation);
- var bullet = bulletInstance.GetComponent<Bullet>();
- bullet.Thorw();
- OnFire?.Invoke();
- }
- }
Add Comment
Please, Sign In to add comment