car occlusion, space ambience done

This commit is contained in:
Timur Nizamov
2025-11-18 22:29:02 +02:00
parent 47d37f2b7f
commit ab737e016c
32 changed files with 812 additions and 35 deletions

View File

@@ -27,7 +27,7 @@ public class CarDrivingRoutine : NetworkBehaviour
private EventInstance CarMovement;
private FirstPersonOcclusion occlusion;
private void Awake()
{
@@ -41,6 +41,13 @@ public class CarDrivingRoutine : NetworkBehaviour
CarMovement.setParameterByName("EasyBoltLogic", 0); //"Driving - 0 in FMOD"
CarMovement.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject)); //setting 3d attributes
occlusion = GetComponent<FirstPersonOcclusion>();
if (occlusion != null)
{
occlusion.InitialiseWithInstance(CarMovement);
}
}
private void Start()
{

View File

@@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using Unity.XR.CoreUtils;
using UnityEngine;
using FMOD.Studio;
public class ElevatorOuter : NetworkBehaviour
{
@@ -25,10 +26,24 @@ public class ElevatorOuter : NetworkBehaviour
public ElevatorStatusPlate statusPlate;
public AudioSource arrivalBeeper;
private EventInstance arrivalBeep;
private FirstPersonOcclusion occlusion;
private void Start()
{
doorOpenTime = box.doorOpenTime;
doorCloseTime = box.doorCloseTime;
arrivalBeep = AudioManager.Instance.CreateInstance(FMODEvents.Instance.ElevatorArrival); //initialising the variable
arrivalBeep.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject)); //setting 3d attributes
occlusion = GetComponent<FirstPersonOcclusion>();
if (occlusion != null)
{
occlusion.InitialiseWithInstance(arrivalBeep);
}
}
private void OnTriggerEnter(Collider other)
{
@@ -77,6 +92,11 @@ public class ElevatorOuter : NetworkBehaviour
Debug.Log("Outer Doors moved");
}
void Update()
{
arrivalBeep.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject)); //updating the attributes
}
}

View File

@@ -23,15 +23,15 @@ public class FloorButtonVisualizer : MonoBehaviour
{
this.ActiveState = true;
buttonImage.sprite = ActiveSprite;
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, gameObject);
// --- Only play hover if selection actually changed ---
if (initialized && lastActiveButton != this)
{
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, gameObject);
}
//if (initialized && lastActiveButton != this)
//{
// AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, gameObject);
//}
lastActiveButton = this;
initialized = true;
//lastActiveButton = this;
//initialized = true;
}
public void Deactivate()

View File

@@ -1,13 +1,14 @@
using FMOD.Studio;
using FMODUnity;
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.XR.CoreUtils;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Rendering;
using UnityEngine.UI;
using UnityEngine.XR.Interaction.Toolkit;
using FMOD.Studio;
using FMODUnity;
public class MenuTeleportButton : MonoBehaviour
{
@@ -28,6 +29,10 @@ public class MenuTeleportButton : MonoBehaviour
private static MenuTeleportButton lastSelectedButton = null;
private static bool initialized = false;
// External state: map must be held/visible
public static bool MapIsOpen = false;
private Menu menu;
private void Awake()
{
TeleportingSound = AudioManager.Instance.CreateInstance(FMODEvents.Instance.Teleport); //initialise the instance
@@ -39,6 +44,7 @@ public class MenuTeleportButton : MonoBehaviour
void Start()
{
button = GetComponent<Button>();
menu = FindObjectOfType<Menu>();
// Subscribe to button events
button.onClick.AddListener(TeleportPlayer);
@@ -66,13 +72,18 @@ public class MenuTeleportButton : MonoBehaviour
button.targetGraphic.GetComponent<Image>().sprite = HoverSprite;
// --- Only play hover sound if selection actually changed ---
if (initialized && lastSelectedButton != this)
{
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, gameObject);
}
//if (initialized && lastSelectedButton != this)
//{
// if (!Menu.IsMapOpen) return;
// if (!menu.MapTab.activeSelf) return; // ensures only map page buttons make sound
// AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, gameObject);
//}
if (!Menu.IsMapOpen) return;
if (!menu.MapTab.activeSelf) return; // ensures only map page buttons make sound
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, gameObject);
lastSelectedButton = this;
initialized = true;
//lastSelectedButton = this;
//initialized = true;
}
}

View File

@@ -59,7 +59,9 @@ public class Menu : MonoBehaviour
private bool hasFloorButtonSoundInitialized = false;
private bool hasMapButtonSoundInitialized = false;
public static bool IsMapOpen { get; private set; }
private void Awake()
{
@@ -93,6 +95,8 @@ public class Menu : MonoBehaviour
hasMapButtonSoundInitialized = true;
SetActiveTab(MenuTab.Map);
IsMapOpen = canvas.enabled;
}
private void activateOptionsPanel()
@@ -125,6 +129,8 @@ public class Menu : MonoBehaviour
public void setCanvasVisibility(bool enabled)
{
canvas.enabled = enabled;
IsMapOpen = enabled;
}
private void ToggleMenu(InputAction.CallbackContext context)

View File

@@ -3376,6 +3376,22 @@ MonoBehaviour:
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- eventID: 1
callback:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 9130699439852735294}
m_TargetAssemblyTypeName: FloorButtonVisualizer, Assembly-CSharp
m_MethodName: Deactivate
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!1 &4122378368372937094
GameObject:
m_ObjectHideFlags: 0
@@ -3580,6 +3596,22 @@ MonoBehaviour:
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- eventID: 1
callback:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2993125651756248496}
m_TargetAssemblyTypeName: FloorButtonVisualizer, Assembly-CSharp
m_MethodName: Deactivate
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!1 &4552840262979230797
GameObject:
m_ObjectHideFlags: 0
@@ -7838,6 +7870,26 @@ PrefabInstance:
value:
objectReference: {fileID: 21300000, guid: 50a077641946fcb48b05e51ec4936afc,
type: 3}
- target: {fileID: 2420913116824796466, guid: f2ade1e8dce12be43ab14956a6244406,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2420913116824796466, guid: f2ade1e8dce12be43ab14956a6244406,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2420913116824796466, guid: f2ade1e8dce12be43ab14956a6244406,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 6428633840807731315}
- target: {fileID: 2420913116824796466, guid: f2ade1e8dce12be43ab14956a6244406,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
value: 2
objectReference: {fileID: 0}
- target: {fileID: 3841795681097067811, guid: f2ade1e8dce12be43ab14956a6244406,
type: 3}
propertyPath: m_Pivot.x
@@ -8068,9 +8120,9 @@ MonoBehaviour:
callback:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 6428633840807731315}
- m_Target: {fileID: 2839451055893527412}
m_TargetAssemblyTypeName: MenuTeleportButton, Assembly-CSharp
m_MethodName:
m_MethodName: SetStateDefault
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}

View File

@@ -8,11 +8,16 @@ public class SpaceEnterCollider : MonoBehaviour
{
public GameObject InstructionText;
private EventInstance PortalEntrance;
private EventInstance PortalEntrance;
private EventInstance SpaceMusic;
private bool musicStarted = false;
private void Awake()
{
PortalEntrance = AudioManager.Instance.CreateInstance(FMODEvents.Instance.PortalEnter);
SpaceMusic = AudioManager.Instance.CreateInstance(FMODEvents.Instance.Kosmos);
SpaceMusic.setParameterByName("KosmosMusicVolume", 1.0f);
}
private void OnTriggerEnter(Collider other)
@@ -46,6 +51,15 @@ public class SpaceEnterCollider : MonoBehaviour
PortalEntrance.start();
if (!musicStarted)
{
SpaceMusic.start();
musicStarted = true;
}
// Fade music in on entering
SpaceMusic.setParameterByName("KosmosMusicVolume", 0f);
}
private void OnTriggerExit(Collider other)
@@ -63,7 +77,8 @@ public class SpaceEnterCollider : MonoBehaviour
Debug.Log(other + " left space.");
PortalEntrance.start();
// Fade music out on leaving
SpaceMusic.setParameterByName("KosmosMusicVolume", 1.0f);
}
private IEnumerator DelayExit(GravityHandler playerGravity)