meta xr, auto fix, occlusion additions
This commit is contained in:
Binary file not shown.
BIN
Assets/Plugins/FMOD/platforms/win/lib/x86_64/MetaLogo.png
LFS
Normal file
BIN
Assets/Plugins/FMOD/platforms/win/lib/x86_64/MetaLogo.png
LFS
Normal file
Binary file not shown.
124
Assets/Plugins/FMOD/platforms/win/lib/x86_64/MetaLogo.png.meta
Normal file
124
Assets/Plugins/FMOD/platforms/win/lib/x86_64/MetaLogo.png.meta
Normal file
@@ -0,0 +1,124 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a872fd50be2db447a17fb4bc7ae6e6f
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/FMOD/platforms/win/lib/x86_64/MetaXRAudioFMOD.dll
LFS
Normal file
BIN
Assets/Plugins/FMOD/platforms/win/lib/x86_64/MetaXRAudioFMOD.dll
LFS
Normal file
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99296f87424cb724baddf545125501a2
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,227 @@
|
||||
studio.plugins.registerPluginDescription("MetaXRAudio Spatializer", {
|
||||
companyName: "Meta",
|
||||
productName: "MetaXRAudio Source",
|
||||
parameters: {
|
||||
"Acoustics": { displayName: "Enable Acoustics" },
|
||||
"Reverb Send": { displayName: "Reverb Send" },
|
||||
"HRTF Intensity": { displayName: "HRTF Intensity" },
|
||||
"V. Radius": { displayName: "Volumetric Radius" },
|
||||
"Refl. Send": { displayName: "Early Reflections Send" },
|
||||
"Directivity": { displayName: "Directivity Pattern", enumeration: ["None", "Human Voice"], },
|
||||
"Dtv. Intensity": { displayName: "Directivity Intensity" },
|
||||
"Direct Enabled": { displayName: "Direct Enabled" },
|
||||
"Reverb Reach": { displayName: "Reverb Reach" },
|
||||
"Occl. Intensity": { displayName: "Occlusion Intensity" },
|
||||
"Medium Absrp.": { displayName: "Medium Absorption" },
|
||||
},
|
||||
|
||||
deckUi: {
|
||||
deckWidgetType: studio.ui.deckWidgetType.Layout,
|
||||
layout: studio.ui.layoutType.HBoxLayout,
|
||||
spacing: 8,
|
||||
items: [
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Layout,
|
||||
layout: studio.ui.layoutType.HBoxLayout,
|
||||
contentsMargins: { left: 6, right: 6 },
|
||||
spacing: 2,
|
||||
items: [
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Layout,
|
||||
layout: studio.ui.layoutType.GridLayout,
|
||||
contentsMargins: { left: 6, right: 6 },
|
||||
spacing: 2,
|
||||
items: [
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.DistanceRolloffGraph,
|
||||
row: 0,
|
||||
column: 0,
|
||||
columnSpan: 2,
|
||||
minimumDistanceBinding: 'Atten. Min',
|
||||
maximumDistanceBinding: 'Atten. Max',
|
||||
rolloffTypeBinding: 'Atten. Mode',
|
||||
rolloffTypes: {
|
||||
0: studio.project.distanceRolloffType.LinearSquared,
|
||||
1: studio.project.distanceRolloffType.Linear,
|
||||
2: studio.project.distanceRolloffType.Inverse,
|
||||
3: studio.project.distanceRolloffType.InverseTapered,
|
||||
4: studio.project.distanceRolloffType.Custom,
|
||||
},
|
||||
},
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Button,
|
||||
binding: "Acoustics",
|
||||
row: 1,
|
||||
column: 0,
|
||||
},
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Dial,
|
||||
binding: "Reverb Send",
|
||||
row: 1,
|
||||
column: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Layout,
|
||||
layout: studio.ui.layoutType.HBoxLayout,
|
||||
contentsMargins: { left: 0, right: 14 },
|
||||
isFramed: true,
|
||||
items: [
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Layout,
|
||||
layout: studio.ui.layoutType.VBoxLayout,
|
||||
contentsMargins: { left: 6, right: 10 },
|
||||
items: [
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Label,
|
||||
text: "Experimental Controls:",
|
||||
},
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Pixmap,
|
||||
filePath: __dirname + "/MetaLogo.png",
|
||||
},
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Dropdown, binding: "Directivity",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Layout,
|
||||
layout: studio.ui.layoutType.VBoxLayout,
|
||||
contentsMargins: { left: 6, right: 10 },
|
||||
spacing: 14,
|
||||
items: [
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Dial, binding: "Dtv. Intensity",
|
||||
},
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Button, binding: "Medium Absrp.",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Layout,
|
||||
layout: studio.ui.layoutType.GridLayout,
|
||||
contentsMargins: { left: 30, right: 30 },
|
||||
spacing: 14,
|
||||
items: [
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Dial, binding: "Refl. Send",
|
||||
row: 0,
|
||||
column: 0,
|
||||
},
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Dial, binding: "V. Radius",
|
||||
row: 1,
|
||||
column: 0,
|
||||
},
|
||||
|
||||
|
||||
],
|
||||
},
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Layout,
|
||||
layout: studio.ui.layoutType.VBoxLayout,
|
||||
contentsMargins: { left: 6, right: 10 },
|
||||
spacing: 14,
|
||||
items: [
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Dial, binding: "HRTF Intensity",
|
||||
row: 1,
|
||||
column: 1,
|
||||
},
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Button, binding: "Direct Enabled",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Layout,
|
||||
layout: studio.ui.layoutType.VBoxLayout,
|
||||
contentsMargins: { left: 6, right: 10 },
|
||||
spacing: 14,
|
||||
items: [
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Dial, binding: "Reverb Reach",
|
||||
},
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Dial, binding: "Occl. Intensity",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{ deckWidgetType: studio.ui.deckWidgetType.OutputMeter, },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
studio.plugins.registerPluginDescription("MetaXRAudio Ambisonics", {
|
||||
companyName: "Meta",
|
||||
productName: "MetaXRAudio Ambisonics",
|
||||
parameters: {},
|
||||
|
||||
deckUi: {
|
||||
deckWidgetType: studio.ui.deckWidgetType.Layout,
|
||||
layout: studio.ui.layoutType.VBoxLayout,
|
||||
contentsMargins: { left: 6, right: 6, top: 6 },
|
||||
spacing: 40,
|
||||
items: [
|
||||
{ deckWidgetType: studio.ui.deckWidgetType.Pixmap, filePath: __dirname + "/MetaLogo.png", },
|
||||
],
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
studio.plugins.registerPluginDescription("MetaXRAudio Reflections", {
|
||||
companyName: "Meta",
|
||||
productName: "MetaXRAudio Reflections",
|
||||
parameters: {
|
||||
"Early Refl.": { displayName: "Early Reflections Enabled" },
|
||||
"Reverb Enabled": { displayName: "Reverb Enabled" },
|
||||
"Reverb Level": { displayName: "Reverb Level" },
|
||||
"Voice Limit": { displayName: "Voice Limit" },
|
||||
},
|
||||
|
||||
deckUi: {
|
||||
deckWidgetType: studio.ui.deckWidgetType.Layout,
|
||||
layout: studio.ui.layoutType.HBoxLayout,
|
||||
contentsMargins: { left: 6, right: 6 },
|
||||
spacing: 12,
|
||||
items: [
|
||||
{ deckWidgetType: studio.ui.deckWidgetType.Pixmap, filePath: __dirname + "/MetaLogo.png" },
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Layout,
|
||||
layout: studio.ui.layoutType.HBoxLayout,
|
||||
contentsMargins: { left: 0, right: 14 },
|
||||
spacing: 8,
|
||||
items: [
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Layout,
|
||||
layout: studio.ui.layoutType.VBoxLayout,
|
||||
contentsMargins: { left: 0, right: 20 },
|
||||
spacing: 14,
|
||||
items: [
|
||||
{ deckWidgetType: studio.ui.deckWidgetType.Button, binding: "Early Refl.", },
|
||||
{ deckWidgetType: studio.ui.deckWidgetType.Button, binding: "Reverb Enabled", },
|
||||
]
|
||||
},
|
||||
{
|
||||
deckWidgetType: studio.ui.deckWidgetType.Layout,
|
||||
layout: studio.ui.layoutType.VBoxLayout,
|
||||
contentsMargins: { left: 0, right: 0 },
|
||||
spacing: 14,
|
||||
items: [
|
||||
{ deckWidgetType: studio.ui.deckWidgetType.Dial, binding: "Reverb Level", },
|
||||
{ deckWidgetType: studio.ui.deckWidgetType.NumberBox, binding: "Voice Limit", },
|
||||
]
|
||||
},
|
||||
],
|
||||
},
|
||||
{ deckWidgetType: studio.ui.deckWidgetType.OutputMeter, },
|
||||
],
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab37959ba9271d444953f8895308ff56
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Resources.meta
Normal file
8
Assets/Resources.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cea7bca5f2b0981489443a1ab4b97e7f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Resources/MetaXRAcousticSettings.asset
LFS
Normal file
BIN
Assets/Resources/MetaXRAcousticSettings.asset
LFS
Normal file
Binary file not shown.
8
Assets/Resources/MetaXRAcousticSettings.asset.meta
Normal file
8
Assets/Resources/MetaXRAcousticSettings.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2af207a59ff0c77449a495a5ff852a9f
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -24,6 +24,9 @@ public class CarDrivingRoutine : NetworkBehaviour
|
||||
private bool stopSoundPlayed = false;
|
||||
private float stopThreshold = 0.05f; // consider speed "0" when below this
|
||||
|
||||
private bool isBeingStoppedByPlayer = false;
|
||||
|
||||
|
||||
[Header("Tires")]
|
||||
public List<GameObject> FrontTires;
|
||||
public List<GameObject> BackTires;
|
||||
@@ -54,25 +57,26 @@ public class CarDrivingRoutine : NetworkBehaviour
|
||||
|
||||
rollTires(); // Just an aesthetic improvement.
|
||||
|
||||
if (Quaternion.Angle(transform.rotation, desiredRotation) > 1f) // If the car is turning.
|
||||
if (!isBeingStoppedByPlayer)
|
||||
{
|
||||
if (!isTurning)
|
||||
if (Quaternion.Angle(transform.rotation, desiredRotation) > 1f)
|
||||
{
|
||||
AudioController.SetRPM(1300); //set externally in CarAudioController.cs
|
||||
setTireRotation(tireTurnAngle);
|
||||
if (!isTurning)
|
||||
{
|
||||
setTireRotation(tireTurnAngle);
|
||||
AudioController.SetRPM(1300);
|
||||
}
|
||||
isTurning = true;
|
||||
}
|
||||
|
||||
isTurning = true;
|
||||
}
|
||||
if (Quaternion.Angle(transform.rotation, desiredRotation) <= 1f) // Reset the turn value.
|
||||
{
|
||||
if (isTurning)
|
||||
else
|
||||
{
|
||||
AudioController.SetRPM(1450);
|
||||
setTireRotation(-tireTurnAngle);
|
||||
if (isTurning)
|
||||
{
|
||||
setTireRotation(-tireTurnAngle);
|
||||
AudioController.SetRPM(1450);
|
||||
}
|
||||
isTurning = false;
|
||||
}
|
||||
|
||||
isTurning = false;
|
||||
}
|
||||
|
||||
// Check if close enough to the waypoint
|
||||
@@ -85,12 +89,14 @@ public class CarDrivingRoutine : NetworkBehaviour
|
||||
|
||||
if (StraightSpeed <= stopThreshold && !stopSoundPlayed)
|
||||
{
|
||||
stopSoundPlayed = true;
|
||||
|
||||
// Play the sound normally from your audio controller
|
||||
//AudioController.SetRPM(475);
|
||||
AudioController.PlayStopSound();
|
||||
|
||||
float currentRPM = AudioController.GetCurrentRPM();
|
||||
//Debug.LogError(currentRPM);
|
||||
if (currentRPM <= 550f) // confirms we are in the correct engine state
|
||||
{
|
||||
stopSoundPlayed = true;
|
||||
AudioController.PlayStopSound();
|
||||
//Debug.LogError("piiks");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,29 +126,29 @@ public class CarDrivingRoutine : NetworkBehaviour
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{;
|
||||
{
|
||||
if (other.GetComponentInParent<XRPlayerMirror>() == null) return;
|
||||
StartCoroutine(SmoothAdjustSpeed(0, 0, haltspeed)); // Smoothly halt in 1 second
|
||||
//_tireSound.Stop();
|
||||
//_stopSound.Play();
|
||||
|
||||
isBeingStoppedByPlayer = true;
|
||||
|
||||
StartCoroutine(SmoothAdjustSpeed(0, 0, haltspeed));
|
||||
|
||||
AudioController.SetRPM(475);
|
||||
//AudioController.PlayStopSound();
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.GetComponentInParent<XRPlayerMirror>() == null) return;
|
||||
StartCoroutine(SmoothAdjustSpeed(targetSpeed, targetRotationSpeed, haltspeed)); // Smoothly resume speed in 1 second
|
||||
//_stopSound.Stop();
|
||||
//_tireSound.Play();
|
||||
|
||||
isBeingStoppedByPlayer = false;
|
||||
|
||||
StartCoroutine(SmoothAdjustSpeed(targetSpeed, targetRotationSpeed, haltspeed));
|
||||
|
||||
AudioController.SetRPM(1450);
|
||||
stopSoundPlayed = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private IEnumerator SmoothAdjustSpeed(float targetStraightSpeed, float targetRotationSpeed, float duration)
|
||||
{
|
||||
float initialStraightSpeed = StraightSpeed;
|
||||
|
||||
@@ -4,6 +4,7 @@ using FMOD.Studio;
|
||||
public class CarAudioController : MonoBehaviour
|
||||
{
|
||||
private EventInstance carMovementInstance;
|
||||
private EventInstance carStopInstance;
|
||||
private FirstPersonOcclusion occlusion;
|
||||
|
||||
private void Awake()
|
||||
@@ -15,13 +16,21 @@ public class CarAudioController : MonoBehaviour
|
||||
//Debug.LogError("Car Simple Driving:");
|
||||
//Debug.LogError(FMODEvents.Instance.BoltCarSimpleDriving);
|
||||
carMovementInstance = AudioManager.Instance.CreateInstance(FMODEvents.Instance.CarModulatedDriving);
|
||||
carStopInstance = AudioManager.Instance.CreateInstance(FMODEvents.Instance.BoltCarStopSound);
|
||||
|
||||
carMovementInstance.setParameterByName("RPM", 1450);
|
||||
carMovementInstance.setParameterByName("Load", 0);
|
||||
|
||||
carMovementInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
|
||||
carStopInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
|
||||
|
||||
occlusion = GetComponent<FirstPersonOcclusion>();
|
||||
|
||||
if (occlusion != null)
|
||||
occlusion.InitialiseWithInstance(carMovementInstance);
|
||||
{
|
||||
occlusion.InitialiseWithInstance(carMovementInstance); // main looping engine sound
|
||||
occlusion.AddInstance(carStopInstance); // additional sound
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
@@ -34,6 +43,7 @@ public class CarAudioController : MonoBehaviour
|
||||
{
|
||||
// Always update 3D position to follow the car model transform
|
||||
carMovementInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
|
||||
carStopInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
|
||||
}
|
||||
|
||||
// These methods are called externally by CarDrivingRoutine
|
||||
@@ -44,8 +54,13 @@ public class CarAudioController : MonoBehaviour
|
||||
|
||||
public void PlayStopSound()
|
||||
{
|
||||
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.BoltCarStopSound, gameObject);
|
||||
carStopInstance.start();
|
||||
//AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.BoltCarStopSound, gameObject);
|
||||
|
||||
}
|
||||
public float GetCurrentRPM()
|
||||
{
|
||||
carMovementInstance.getParameterByName("RPM", out float value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -2,6 +2,7 @@ using UnityEngine;
|
||||
using FMODUnity;
|
||||
using FMOD.Studio;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic; // ADDED
|
||||
|
||||
public class FirstPersonOcclusion : MonoBehaviour
|
||||
{
|
||||
@@ -26,6 +27,10 @@ public class FirstPersonOcclusion : MonoBehaviour
|
||||
|
||||
private bool initialisedExternally = false;
|
||||
|
||||
// ADDED: now stores ALL event instances that must be occluded
|
||||
private List<EventInstance> managedInstances = new List<EventInstance>();
|
||||
|
||||
|
||||
public void InitialiseWithInstance(EventInstance instance)
|
||||
{
|
||||
AudioOccluded = instance;
|
||||
@@ -37,9 +42,28 @@ public class FirstPersonOcclusion : MonoBehaviour
|
||||
GetComponent<Rigidbody>()
|
||||
);
|
||||
|
||||
managedInstances.Add(AudioOccluded); // ADDED
|
||||
|
||||
AudioOccluded.getDescription(out AudioDes);
|
||||
AudioDes.getMinMaxDistance(out float min, out MaxDistance);
|
||||
}
|
||||
|
||||
// ADDED: allows adding extra FMOD instances for occlusion
|
||||
public void AddInstance(EventInstance instance)
|
||||
{
|
||||
if (instance.isValid())
|
||||
{
|
||||
RuntimeManager.AttachInstanceToGameObject(
|
||||
instance,
|
||||
gameObject,
|
||||
GetComponent<Rigidbody>()
|
||||
);
|
||||
|
||||
managedInstances.Add(instance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private IEnumerator Start()
|
||||
{
|
||||
// If already initialised, skip internal creation
|
||||
@@ -47,13 +71,18 @@ public class FirstPersonOcclusion : MonoBehaviour
|
||||
if (!initialisedExternally)
|
||||
{
|
||||
AudioOccluded = RuntimeManager.CreateInstance(SelectAudio);
|
||||
|
||||
// 2. Attaching Instance
|
||||
RuntimeManager.AttachInstanceToGameObject(AudioOccluded, gameObject);
|
||||
|
||||
// 3. Starting Audio
|
||||
AudioOccluded.start();
|
||||
|
||||
// 4. Releasing Instance (This allows the event to self-manage its lifetime, which is fine)
|
||||
AudioOccluded.release();
|
||||
|
||||
managedInstances.Add(AudioOccluded); // ADDED
|
||||
|
||||
// 5. Getting Event Description and Max Distance
|
||||
AudioDes = RuntimeManager.GetEventDescription(SelectAudio);
|
||||
AudioDes.getMinMaxDistance(out float minDistance, out MaxDistance);
|
||||
@@ -64,6 +93,7 @@ public class FirstPersonOcclusion : MonoBehaviour
|
||||
Listener = FindObjectOfType<StudioListener>();
|
||||
}
|
||||
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (Listener == null) return;
|
||||
@@ -82,6 +112,7 @@ public class FirstPersonOcclusion : MonoBehaviour
|
||||
lineCastHitCount = 0f;
|
||||
}
|
||||
|
||||
|
||||
private void OccludeBetween(Vector3 sound, Vector3 listener)
|
||||
{
|
||||
// 9. Calculate Points (Log only a few to avoid clutter)
|
||||
@@ -117,6 +148,7 @@ public class FirstPersonOcclusion : MonoBehaviour
|
||||
SetParameter();
|
||||
}
|
||||
|
||||
|
||||
private Vector3 CalculatePoint(Vector3 a, Vector3 b, float m, bool posOrneg)
|
||||
{
|
||||
float n = Vector3.Distance(new Vector3(a.x, 0f, a.z), new Vector3(b.x, 0f, b.z));
|
||||
@@ -139,9 +171,11 @@ public class FirstPersonOcclusion : MonoBehaviour
|
||||
return new Vector3(x, a.y, z);
|
||||
}
|
||||
|
||||
|
||||
private void CastLine(Vector3 Start, Vector3 End)
|
||||
{
|
||||
RaycastHit hit;
|
||||
|
||||
// 11. Raycast result
|
||||
bool isHit = Physics.Linecast(Start, End, out hit, OcclusionLayer);
|
||||
|
||||
@@ -156,10 +190,18 @@ public class FirstPersonOcclusion : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SetParameter()
|
||||
{
|
||||
float occlusionValue = lineCastHitCount / 11;
|
||||
|
||||
// 12. Final Parameter Value
|
||||
AudioOccluded.setParameterByName("Occlusion", occlusionValue);
|
||||
foreach (var inst in managedInstances)
|
||||
{
|
||||
if (inst.isValid())
|
||||
{
|
||||
inst.setParameterByName("Occlusion", occlusionValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user