sounds for prefabs

This commit is contained in:
joonasp
2022-03-21 17:52:47 +02:00
parent 22e4260521
commit f0649da5d3
9 changed files with 447 additions and 6 deletions

View File

@@ -5,9 +5,17 @@ using UnityEngine.XR.Interaction.Toolkit;
public class EssenceNodeController : MonoBehaviour
{
[SerializeField]
private AudioSource chime;
public void Touched()
{
GetComponent<Renderer>().material.color = Color.cyan;
chime.Play();
}
public void SetPitch(float value)
{
chime.pitch = value;
}
}

View File

@@ -27,6 +27,9 @@ public class LeverController : MonoBehaviour
public float hapticAmplitude = 1f;
public float hapticDuration = 0.1f;
public AudioSource upSound;
public AudioSource downSound;
//This script cannot work with multiplayer, see CheckHand() method
public Transform leftHand;
public Transform rightHand;
@@ -57,6 +60,7 @@ public class LeverController : MonoBehaviour
{
onUp.Invoke();
grabHand.gameObject.GetComponent<ActionBasedController>().SendHapticImpulse(hapticAmplitude, hapticDuration);
if (upSound != null) upSound.Play();
leverDown = false;
}
}
@@ -67,6 +71,7 @@ public class LeverController : MonoBehaviour
{
onDown.Invoke();
grabHand.gameObject.GetComponent<ActionBasedController>().SendHapticImpulse(hapticAmplitude, hapticDuration);
if (downSound != null) downSound.Play();
leverDown = true;
}
}

View File

@@ -31,9 +31,15 @@ public class WellController : MonoBehaviour
{
if(i == numberOfNodes) yield break;
Instantiate(node, nodeSpawn, Quaternion.identity);
nodeSpawn = nodeSpawn + (right * 0.2f);
GameObject tempNode = Instantiate(node, nodeSpawn, Quaternion.identity);
tempNode.GetComponent<AudioSource>().pitch += (i * (1f / numberOfNodes));
nodeSpawn = nodeSpawn + right * 0.2f + Random.Range(-0.2f, 0.2f) * up;
yield return new WaitForSeconds(2f);
StartCoroutine(SpawnNode(nodeSpawn, i+1));
}
private void Update()
{
transform.Rotate(0.5f, 0.5f, 0.5f);
}
}