forked from cgvr/DeltaVR
Add bow sounds, fix 2nd floor roof, add lights to archery range
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Audio;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
|
||||
@@ -7,6 +8,8 @@ namespace Bow
|
||||
{
|
||||
public class Arrow : XRGrabInteractable
|
||||
{
|
||||
public AudioClipGroup hitSounds;
|
||||
|
||||
public float speed = 2000.0f;
|
||||
public Transform tip = null;
|
||||
|
||||
@@ -37,6 +40,7 @@ namespace Bow
|
||||
hit.collider.gameObject.SendMessage("OnArrowHit", this,
|
||||
SendMessageOptions.DontRequireReceiver);
|
||||
Stop();
|
||||
hitSounds.Play();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
using Audio;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
|
||||
namespace Bow
|
||||
{
|
||||
public class Notch : XRSocketInteractor
|
||||
{
|
||||
public AudioClipGroup nockSounds;
|
||||
public AudioClipGroup releaseSounds;
|
||||
|
||||
private Puller _puller = null;
|
||||
private Arrow _currentArrow = null;
|
||||
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
@@ -34,10 +37,10 @@ namespace Bow
|
||||
|
||||
private void StoreArrow(XRBaseInteractable interactable)
|
||||
{
|
||||
if (interactable is Arrow arrow)
|
||||
{
|
||||
_currentArrow = arrow;
|
||||
}
|
||||
if (!(interactable is Arrow arrow)) return;
|
||||
|
||||
_currentArrow = arrow;
|
||||
nockSounds.Play();
|
||||
}
|
||||
|
||||
private void TryToReleaseArrow(XRBaseInteractor interactor)
|
||||
@@ -60,6 +63,7 @@ namespace Bow
|
||||
{
|
||||
_currentArrow.Release(_puller.PullAmount);
|
||||
_currentArrow = null;
|
||||
releaseSounds.Play();
|
||||
}
|
||||
|
||||
public override XRBaseInteractable.MovementType? selectedInteractableMovementTypeOverride =>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using Audio;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
|
||||
namespace Bow
|
||||
@@ -6,6 +7,9 @@ namespace Bow
|
||||
public class Puller : XRBaseInteractable
|
||||
{
|
||||
public float PullAmount { get; private set; } = 0.0f;
|
||||
public AudioClipGroup pullSounds;
|
||||
public AudioClipGroup maxPullSounds;
|
||||
|
||||
|
||||
public Transform start = null;
|
||||
public Transform end = null;
|
||||
@@ -33,7 +37,19 @@ namespace Bow
|
||||
if (!isSelected) return;
|
||||
|
||||
Vector3 pullPosition = _pullingInteractor.transform.position;
|
||||
PullAmount = CalculatePull(pullPosition);
|
||||
|
||||
float newPull = CalculatePull(pullPosition);
|
||||
if (PullAmount == 0 & newPull > 0)
|
||||
{
|
||||
pullSounds.Play();
|
||||
}
|
||||
|
||||
if (PullAmount < 0.98f & newPull >= 0.98f)
|
||||
{
|
||||
maxPullSounds.Play();
|
||||
}
|
||||
|
||||
PullAmount = newPull;
|
||||
}
|
||||
|
||||
private float CalculatePull(Vector3 pullPosition)
|
||||
|
||||
Reference in New Issue
Block a user