NEW HVR 2.9.1f
This commit is contained in:
@@ -22,13 +22,14 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
}
|
||||
}
|
||||
|
||||
private void OnStringGrabbed(HVRHandGrabber arg0, HVRGrabbable arg1)
|
||||
private void OnStringGrabbed(HVRHandGrabber hand, HVRGrabbable arg1)
|
||||
{
|
||||
if (!bow.ArrowNocked && ArrowPrefab)
|
||||
{
|
||||
var go = Instantiate(ArrowPrefab);
|
||||
var arrow = go.GetComponent<HVRArrow>();
|
||||
bow.NockArrow(arrow);
|
||||
hand.DisableHandCollision(arrow.Grabbable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,13 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
{
|
||||
[Header("Bow String")]
|
||||
public HVRGrabbable NockGrabbable;
|
||||
|
||||
public float StringLimit = .5f;
|
||||
public float StringDropLimit = .6f;
|
||||
|
||||
[Header("Settings")]
|
||||
public HVRBowLimitStyle StringLimitStyle = HVRBowLimitStyle.Limit;
|
||||
|
||||
public float ShootThreshold = .2f;
|
||||
public float Speed = 50f;
|
||||
public AnimationCurve SpeedCurve;
|
||||
@@ -27,7 +29,6 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
|
||||
|
||||
[Header("Transforms")]
|
||||
|
||||
[Tooltip("Arrow Rest When the bow is held with the left hand.")]
|
||||
public Transform LeftRest;
|
||||
|
||||
@@ -39,6 +40,7 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
|
||||
[Header("Haptics")]
|
||||
public bool StringHaptics = true;
|
||||
|
||||
public bool BowHandHaptics = true;
|
||||
|
||||
[Tooltip("Number of haptic ticks by percent traveled.")]
|
||||
@@ -61,6 +63,7 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
|
||||
[Header("SFX")]
|
||||
public AudioClip StringClip;
|
||||
|
||||
public float StringMinPitch = 1f;
|
||||
public float StringMaxPitch = 1.25f;
|
||||
|
||||
@@ -137,8 +140,6 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
@@ -147,7 +148,6 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
|
||||
protected virtual void UpdateBow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
@@ -159,12 +159,10 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
|
||||
protected virtual void BeforeFixedUpdateBow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected virtual void AfterFixedUpdateBow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected virtual void FixedUpdateBow()
|
||||
@@ -272,22 +270,20 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
protected virtual void PlayStringSFX(float nockDistance)
|
||||
{
|
||||
var pitch = nockDistance.Remap(0, StringLimit, StringMinPitch, StringMaxPitch);
|
||||
if(SFXPlayer.Instance) SFXPlayer.Instance.PlaySFX(StringClip, NockGrabbable.transform.position, pitch, 1f);
|
||||
if (SFXPlayer.Instance) SFXPlayer.Instance.PlaySFX(StringClip, NockGrabbable.transform.position, pitch, 1f);
|
||||
}
|
||||
|
||||
protected virtual void PlayReleasedSFX()
|
||||
{
|
||||
if(SFXPlayer.Instance) SFXPlayer.Instance.PlaySFX(ReleasedSFX.GetRandom(), NockGrabbable.transform.position);
|
||||
if (SFXPlayer.Instance) SFXPlayer.Instance.PlaySFX(ReleasedSFX.GetRandom(), NockGrabbable.transform.position);
|
||||
}
|
||||
|
||||
protected virtual void OnGrabbed(HVRGrabberBase arg0, HVRGrabbable arg1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected virtual void OnReleased(HVRGrabberBase arg0, HVRGrabbable arg1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void BeforeNockHovered(HVRGrabberBase grabber, HVRGrabbable grabbable)
|
||||
@@ -318,7 +314,7 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
|
||||
|
||||
var grabbable = arrow.Grabbable;
|
||||
grabbable.ForceRelease();
|
||||
//grabbable.ForceRelease();
|
||||
grabbable.CanBeGrabbed = false;
|
||||
grabbable.Rigidbody.sleepThreshold = 0f;
|
||||
grabbable.Grabbed.AddListener(OnNockedArrowGrabbed);
|
||||
@@ -332,6 +328,7 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
|
||||
if (NockHand)
|
||||
{
|
||||
NockHand.DisableHandCollision(Arrow.Grabbable);
|
||||
NockHand.TryGrab(NockGrabbable, true);
|
||||
NockHand = null;
|
||||
}
|
||||
@@ -369,17 +366,16 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
{
|
||||
StartCoroutine(EnableBowHandCollisionRoutine(arg0, Arrow.Grabbable));
|
||||
}
|
||||
|
||||
BowHand = null;
|
||||
}
|
||||
|
||||
protected virtual void OnStringReleased(HVRHandGrabber arg0, HVRGrabbable arg1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected virtual void OnStringGrabbed(HVRHandGrabber hand, HVRGrabbable nock)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected virtual void OnBowSocketed(HVRSocket arg0, HVRGrabbable arg1)
|
||||
@@ -392,7 +388,6 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
|
||||
protected virtual void OnBowUnsocketed(HVRSocket arg0, HVRGrabbable arg1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected virtual void OnArrowDropped()
|
||||
@@ -403,7 +398,6 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
Arrow.Grabbable.CanBeGrabbed = true;
|
||||
|
||||
Arrow = null;
|
||||
|
||||
}
|
||||
|
||||
protected virtual void OnArrowRemoved(HVRArrow arrow)
|
||||
@@ -429,10 +423,11 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
{
|
||||
if (!hand || !arrow)
|
||||
yield break;
|
||||
yield return new WaitForSeconds(.25f);
|
||||
yield return new WaitForSeconds(1f);
|
||||
if (BowHand && BowHand == hand || !arrow)
|
||||
yield break;
|
||||
UpdateBowHandCollision(hand, arrow, true);
|
||||
Grabbable.IgnoreCollision(arrow, false);
|
||||
}
|
||||
|
||||
public void OnDrawGizmosSelected()
|
||||
@@ -457,6 +452,5 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
|
||||
public class HVRBowEvent : UnityEvent<HVRPhysicsBow>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using HurricaneVR.Framework.Core.Grabbers;
|
||||
using HurricaneVR.Framework.Core;
|
||||
using HurricaneVR.Framework.Core.Grabbers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HurricaneVR.Framework.Weapons.Bow
|
||||
@@ -18,10 +19,21 @@ namespace HurricaneVR.Framework.Weapons.Bow
|
||||
|
||||
protected override void OnGrabbed(HVRGrabArgs args)
|
||||
{
|
||||
Debug.Log($"nocked");
|
||||
//Debug.Log($"nocked");
|
||||
args.Cancel = true;
|
||||
Grabbed.Invoke(this, args.Grabbable);
|
||||
ForceRelease();
|
||||
//ForceRelease();
|
||||
}
|
||||
|
||||
protected override void OnReleased(HVRGrabbable grabbable)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHoverEnter(HVRGrabbable grabbable)
|
||||
{
|
||||
if (grabbable.LeftHandGrabber) grabbable.LeftHandGrabber.IgnoreNextCollisionCheck = true;
|
||||
if (grabbable.RightHandGrabber) grabbable.RightHandGrabber.IgnoreNextCollisionCheck = true;
|
||||
base.OnHoverEnter(grabbable);
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
-16
@@ -62,6 +62,10 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
private Transform _grabbedPositionTracker;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The offset of the cocking handle when it's grabbed
|
||||
/// </summary>
|
||||
protected float GrabOffset { get; set; }
|
||||
|
||||
public bool EmptyOpen { get; protected set; }
|
||||
|
||||
@@ -160,27 +164,27 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
return;
|
||||
}
|
||||
|
||||
var pullDirection = (Grabbable.HandGrabbers[0].TrackedController.position - _grabbedPositionTracker.transform.position);
|
||||
var pullDirection = (Grabbable.HandGrabbers[0].TrackedController.position - _grabbedPositionTracker.position);
|
||||
var backDirection = (MaxPositionWorld - ForwardPositionWorld).normalized * 10;
|
||||
var amount = Vector3.Dot(pullDirection, backDirection);
|
||||
var amount = Vector3.Dot(pullDirection, backDirection) * Difficulty;
|
||||
|
||||
if (amount > 0)
|
||||
if (amount + GrabOffset > 0)
|
||||
{
|
||||
UpdatePosition(amount);
|
||||
|
||||
var distance = Vector3.Distance(transform.position, ForwardPositionWorld);
|
||||
|
||||
CheckEject(distance);
|
||||
CheckChamberDistance(distance);
|
||||
ClampPullBack(distance, BackDirectionWorld);
|
||||
MoveBolt();
|
||||
AnimateParts();
|
||||
CheckLock(distance);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.localPosition = ForwardPosition;
|
||||
}
|
||||
|
||||
var distance = Vector3.Distance(transform.position, ForwardPositionWorld);
|
||||
|
||||
CheckEject(distance);
|
||||
CheckChamberDistance(distance);
|
||||
ClampPullBack(distance, BackDirectionWorld);
|
||||
MoveBolt();
|
||||
AnimateParts();
|
||||
CheckLock(distance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,8 +206,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
|
||||
private void UpdatePosition(float amount)
|
||||
{
|
||||
|
||||
transform.position = ForwardPositionWorld + BackDirectionWorld * (amount * Difficulty);
|
||||
transform.position = ForwardPositionWorld + BackDirectionWorld * (amount + GrabOffset);
|
||||
}
|
||||
|
||||
|
||||
@@ -337,6 +340,8 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
|
||||
protected virtual void OnGrabbed(HVRHandGrabber grabber, HVRGrabbable slide)
|
||||
{
|
||||
GrabOffset = 0f;
|
||||
|
||||
if (ImmediateReleaseWhenOpen && EmptyOpen && LocksBack)
|
||||
{
|
||||
if (Bolt)
|
||||
@@ -350,14 +355,17 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
_previousVelocity = Vector3.zero;
|
||||
if (Type == HVRCockingHandleType.Pump)
|
||||
{
|
||||
_grabbedPositionTracker.transform.position = grabber.GrabPoint.position;
|
||||
_grabbedPositionTracker.position = grabber.GrabPoint.position;
|
||||
}
|
||||
else
|
||||
{
|
||||
_grabbedPositionTracker.transform.localPosition = transform.parent.InverseTransformPoint(_previousHandPosition);
|
||||
_grabbedPositionTracker.localPosition = transform.parent.InverseTransformPoint(_previousHandPosition);
|
||||
GrabOffset = Vector3.Distance(ForwardPositionWorld, transform.position);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected virtual void OnReleased(HVRHandGrabber grabber, HVRGrabbable slide)
|
||||
{
|
||||
EmptyOpen = false;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HurricaneVR.Framework.Components;
|
||||
@@ -36,7 +37,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
|
||||
[Tooltip("Is chambering required to shoot")]
|
||||
public bool RequiresChamberedBullet = true;
|
||||
public FireType FireType = FireType.Single;
|
||||
public GunFireType FireType = GunFireType.Single;
|
||||
|
||||
[Tooltip("Speed of the bullet prefab")]
|
||||
public float BulletSpeed = 40f;
|
||||
@@ -126,7 +127,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
private Coroutine _animationRoutine;
|
||||
|
||||
public UnityEvent Fired = new UnityEvent();
|
||||
public GunHitEvent Hit = new GunHitEvent();
|
||||
public HVRGunHitEvent Hit = new HVRGunHitEvent();
|
||||
|
||||
protected float TimeOfLastShot { get; set; }
|
||||
|
||||
@@ -554,7 +555,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
return;
|
||||
}
|
||||
|
||||
if (FireType == FireType.Single)
|
||||
if (FireType == GunFireType.Single)
|
||||
{
|
||||
if (Time.time - TimeOfLastShot < Cooldown)
|
||||
return;
|
||||
@@ -565,7 +566,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsFiring && FireType == FireType.ThreeRoundBurst)
|
||||
if (IsFiring && FireType == GunFireType.ThreeRoundBurst)
|
||||
return;
|
||||
|
||||
IsFiring = true;
|
||||
@@ -574,7 +575,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
|
||||
public virtual void TriggerReleased()
|
||||
{
|
||||
if (FireType == FireType.Automatic)
|
||||
if (FireType == GunFireType.Automatic)
|
||||
{
|
||||
IsFiring = false;
|
||||
}
|
||||
@@ -602,7 +603,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
PlayHaptics(Grabbable, Haptics.DryFire);
|
||||
}
|
||||
|
||||
public virtual void UpdateTrackedBullets()
|
||||
private void UpdateTrackedBullets()
|
||||
{
|
||||
for (int i = 0; i < _objects.Count; i++)
|
||||
{
|
||||
@@ -615,7 +616,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
|
||||
if (Physics.Raycast(bullet.transform.position, tracker.Direction, out var hit, distance, HitLayerMask, QueryTriggerInteraction.Ignore))
|
||||
{
|
||||
OnHit(bullet, hit, tracker.Direction);
|
||||
OnHit(hit, tracker.Direction);
|
||||
bullet.SetActive(false);
|
||||
_objects[i].SetRenderersActive(false);
|
||||
}
|
||||
@@ -708,7 +709,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
TimeOfLastShot = Time.time;
|
||||
RoundsFired++;
|
||||
|
||||
if (FireType == FireType.ThreeRoundBurst && RoundsFired == 3)
|
||||
if (FireType == GunFireType.ThreeRoundBurst && RoundsFired == 3)
|
||||
{
|
||||
IsFiring = false;
|
||||
}
|
||||
@@ -1005,7 +1006,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
}
|
||||
|
||||
|
||||
protected virtual void OnHit(GameObject bullet, RaycastHit hit, Vector3 direction)
|
||||
protected virtual void OnHit(RaycastHit hit, Vector3 direction)
|
||||
{
|
||||
var damageHandler = hit.collider.GetComponent<HVRDamageHandlerBase>();
|
||||
if (damageHandler)
|
||||
@@ -1020,7 +1021,7 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
hit.collider.attachedRigidbody.AddForceAtPosition(direction.normalized * Force, hit.point, ForceMode.Impulse);
|
||||
}
|
||||
|
||||
Hit.Invoke(damageHandler);
|
||||
Hit.Invoke(new GunHitArgs(this, direction, hit));
|
||||
}
|
||||
|
||||
public virtual void EjectBullet()
|
||||
@@ -1126,4 +1127,39 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class HVRGunHitEvent : UnityEvent<GunHitArgs>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public struct GunHitArgs
|
||||
{
|
||||
public HVRGunBase Gun;
|
||||
public Vector3 HitPoint;
|
||||
public Vector3 Normal;
|
||||
public Vector3 Direction;
|
||||
public Collider Collider;
|
||||
public Rigidbody Rb;
|
||||
public float Distance;
|
||||
|
||||
public GunHitArgs(HVRGunBase gun, Vector3 direction, RaycastHit hit)
|
||||
{
|
||||
Gun = gun;
|
||||
HitPoint = hit.point;
|
||||
Normal = hit.normal;
|
||||
Direction = direction;
|
||||
Collider = hit.collider;
|
||||
Rb = hit.collider.attachedRigidbody;
|
||||
Distance = hit.distance;
|
||||
}
|
||||
}
|
||||
|
||||
public enum GunFireType
|
||||
{
|
||||
Single,
|
||||
ThreeRoundBurst,
|
||||
Automatic
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using UnityEngine;
|
||||
using HurricaneVR.Framework.Core;
|
||||
using HurricaneVR.Framework.Core.Grabbers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HurricaneVR.Framework.Weapons.Guns
|
||||
{
|
||||
@@ -32,5 +34,15 @@ namespace HurricaneVR.Framework.Weapons.Guns
|
||||
EjectCasing();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnAmmoSocketed(HVRGrabberBase grabber, HVRGrabbable grabbable)
|
||||
{
|
||||
AmmoSocketedHaptics();
|
||||
}
|
||||
|
||||
protected override void OnAmmoSocketReleased(HVRGrabberBase arg0, HVRGrabbable arg1)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,14 +11,12 @@ namespace HurricaneVR.Framework.Weapons
|
||||
|
||||
public class HVRAmmoReleaseAction : HVRInputAction
|
||||
{
|
||||
public HVRRayCastGun HVRRayCastGun { get; private set; }
|
||||
public HVRGunBase Gun { get; private set; }
|
||||
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
HVRRayCastGun = GetComponent<HVRRayCastGun>();
|
||||
Gun = GetComponent<HVRGunBase>();
|
||||
}
|
||||
|
||||
@@ -41,10 +39,9 @@ namespace HurricaneVR.Framework.Weapons
|
||||
release = controller.PrimaryButtonState.JustActivated;
|
||||
}
|
||||
|
||||
if (release)
|
||||
if (release && Gun)
|
||||
{
|
||||
HVRRayCastGun?.ReleaseAmmo();
|
||||
Gun?.ReleaseAmmo();
|
||||
Gun.ReleaseAmmo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +1,92 @@
|
||||
using FMODUnity;
|
||||
using System.Collections.Generic;
|
||||
using HurricaneVR.Framework.Core.Utils;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace HurricaneVR.Framework.Weapons
|
||||
{
|
||||
public class HVRGunSounds : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private EventReference fired;
|
||||
[SerializeField] private EventReference outOfAmmo;
|
||||
[SerializeField] private EventReference slideBack;
|
||||
[SerializeField] private EventReference slideForward;
|
||||
[SerializeField] private EventReference loadMagazine;
|
||||
[SerializeField] private EventReference unloadMagazine;
|
||||
|
||||
public AudioClip Fired;
|
||||
public AudioClip OutOfAmmo;
|
||||
|
||||
//public AudioClip AmmoInserted;
|
||||
//public AudioClip AmmoReleased;
|
||||
|
||||
public AudioClip SlideBack;
|
||||
public AudioClip SlideForward;
|
||||
|
||||
public List<AudioClip> FiredVariations = new List<AudioClip>();
|
||||
//public List<AudioClip> AmmoInsertedVariations = new List<AudioClip>();
|
||||
//public List<AudioClip> AmmoReleasedVariations = new List<AudioClip>();
|
||||
|
||||
public List<AudioClip> SlideBackVariations = new List<AudioClip>();
|
||||
public List<AudioClip> SlideForwardVariations = new List<AudioClip>();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
AddVariation(Fired, FiredVariations);
|
||||
//AddVariation(AmmoInserted, AmmoInsertedVariations);
|
||||
//AddVariation(AmmoReleased, AmmoReleasedVariations);
|
||||
AddVariation(SlideBack, SlideBackVariations);
|
||||
AddVariation(SlideForward, SlideForwardVariations);
|
||||
}
|
||||
|
||||
public virtual void PlayGunFire()
|
||||
{
|
||||
PlayClip(fired);
|
||||
PlayVariation(FiredVariations);
|
||||
}
|
||||
|
||||
|
||||
//public virtual void PlayAmmoInserted()
|
||||
//{
|
||||
// PlayVariation(AmmoInsertedVariations);
|
||||
//}
|
||||
|
||||
//public virtual void PlayAmmoReleased()
|
||||
//{
|
||||
// PlayVariation(AmmoReleasedVariations);
|
||||
//}
|
||||
|
||||
public virtual void PlayOutOfAmmo()
|
||||
{
|
||||
PlayClip(outOfAmmo);
|
||||
PlayClip(OutOfAmmo);
|
||||
}
|
||||
|
||||
public virtual void PlaySlideForward()
|
||||
{
|
||||
PlayClip(slideForward);
|
||||
PlayVariation(SlideForwardVariations);
|
||||
}
|
||||
|
||||
public virtual void PlaySlideBack()
|
||||
{
|
||||
PlayClip(slideBack);
|
||||
PlayVariation(SlideBackVariations);
|
||||
}
|
||||
|
||||
public virtual void PlayLoadMagazine()
|
||||
protected virtual void PlayVariation(List<AudioClip> variations)
|
||||
{
|
||||
PlayClip(loadMagazine);
|
||||
if (variations.Count == 0)
|
||||
return;
|
||||
|
||||
var index = Random.Range(0, variations.Count);
|
||||
var sfx = variations[index];
|
||||
|
||||
PlayClip(sfx);
|
||||
}
|
||||
|
||||
public virtual void PlayUnloadMagazine()
|
||||
protected virtual void PlayClip(AudioClip clip)
|
||||
{
|
||||
PlayClip(unloadMagazine);
|
||||
if (!clip)
|
||||
return;
|
||||
|
||||
if(SFXPlayer.Instance) SFXPlayer.Instance.PlaySFX(clip, transform.position);
|
||||
}
|
||||
|
||||
protected virtual void PlayClip(EventReference clip)
|
||||
|
||||
private void AddVariation(AudioClip clip, List<AudioClip> variations)
|
||||
{
|
||||
if (clip.IsNull) return;
|
||||
RuntimeManager.PlayOneShot(clip.Guid, transform.position);
|
||||
if (clip && !variations.Contains(clip))
|
||||
{
|
||||
variations.Add(clip);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user