You've already forked zumbi-game
add shoot sfx and gun trigger
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class GunController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private InputActionReference rightTriggerAction;
|
||||
|
||||
[Header("Audio")]
|
||||
[SerializeField] private AudioSource audioSource;
|
||||
[SerializeField] private AudioClip triggerSoundEffect;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
rightTriggerAction.action.Enable();
|
||||
rightTriggerAction.action.performed += OnTriggerPressed;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
rightTriggerAction.action.performed -= OnTriggerPressed;
|
||||
rightTriggerAction.action.Disable();
|
||||
}
|
||||
|
||||
private void OnTriggerPressed(InputAction.CallbackContext context)
|
||||
{
|
||||
HandleShoot();
|
||||
}
|
||||
|
||||
private void HandleShoot()
|
||||
{
|
||||
Debug.Log("Shoot!");
|
||||
audioSource.PlayOneShot(triggerSoundEffect);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 200aefe84ef30164e840f8cb581b9308
|
||||
Reference in New Issue
Block a user