This commit is contained in:
OliverS 2024-02-04 02:20:31 +01:00
commit b80c9d960f
4 changed files with 70 additions and 1 deletions

View File

@ -1604,6 +1604,9 @@ PrefabInstance:
- targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} - targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
insertIndex: -1 insertIndex: -1
addedObject: {fileID: 1579580571} addedObject: {fileID: 1579580571}
- targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
insertIndex: -1
addedObject: {fileID: 1579580572}
m_SourcePrefab: {fileID: 100100000, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 30e0cc55a67f02d4f92b2677ec4b1511, type: 3}
--- !u!114 &869964774 stripped --- !u!114 &869964774 stripped
MonoBehaviour: MonoBehaviour:
@ -1774,6 +1777,9 @@ PrefabInstance:
- targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} - targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3}
insertIndex: -1 insertIndex: -1
addedObject: {fileID: 1254139636} addedObject: {fileID: 1254139636}
- targetCorrespondingSourceObject: {fileID: 3120938410244321186, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3}
insertIndex: -1
addedObject: {fileID: 1254139637}
m_SourcePrefab: {fileID: 100100000, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 99a6ff8b9591949439b620b13bd249a4, type: 3}
--- !u!114 &1232208433 stripped --- !u!114 &1232208433 stripped
MonoBehaviour: MonoBehaviour:
@ -1895,6 +1901,19 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
invert: 0 invert: 0
--- !u!114 &1254139637
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1254139629}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d4d58ce9310f45c42af5d8003f1a832c, type: 3}
m_Name:
m_EditorClassIdentifier:
StepInterval: 0.8
--- !u!1 &1377274208 --- !u!1 &1377274208
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -3403,6 +3422,19 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
invert: 0 invert: 0
--- !u!114 &1579580572
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1579580564}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d4d58ce9310f45c42af5d8003f1a832c, type: 3}
m_Name:
m_EditorClassIdentifier:
StepInterval: 0.8
--- !u!1 &1600052931 --- !u!1 &1600052931
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -2,6 +2,7 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Unity.VisualScripting;
using UnityEngine; using UnityEngine;
@ -35,7 +36,7 @@ public class AudioManager : MonoBehaviour
return Instance.audioLibrary.Clips.First(x => x.name == nameOfClip); return Instance.audioLibrary.Clips.First(x => x.name == nameOfClip);
} }
public static AudioSource PlaySound(string nameOfClip, Vector3 sourcePos, bool is3D, bool loop = false, bool fadeIn = false) public static AudioSource PlaySound(string nameOfClip, Vector3 sourcePos, bool is3D = true, bool loop = false, bool fadeIn = false)
{ {
if (Instance == null) if (Instance == null)
{ {
@ -48,6 +49,7 @@ public class AudioManager : MonoBehaviour
audioSource.loop = loop; audioSource.loop = loop;
audioSource.clip = FindAudioClip(nameOfClip); audioSource.clip = FindAudioClip(nameOfClip);
sourceObject.transform.position = sourcePos; sourceObject.transform.position = sourcePos;
sourceObject.transform.parent = Instance.transform;
if (is3D) if (is3D)
{ {

View File

@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FootStepSounder : MonoBehaviour
{
[SerializeField] private float StepInterval = 0.5f;
[SerializeField] private float Volume = 0.25f;
private float movedDist = 0;
private Vector3 prevPos;
// Update is called once per frame
void Update()
{
movedDist += Vector3.Distance(transform.position, prevPos);
if (movedDist % StepInterval < 0.1f)
{
AudioManager.PlaySound("Footstep_" + UnityEngine.Random.Range(0, 6), transform.position, true).volume = Volume;
}
prevPos = transform.position;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d4d58ce9310f45c42af5d8003f1a832c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: