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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user