some sound bug fixes

This commit is contained in:
Timur Nizamov
2025-11-16 16:01:23 +02:00
parent e12c5f2f98
commit ef3b4c363e
40 changed files with 476 additions and 322 deletions

View File

@@ -28,6 +28,7 @@ public class CarDrivingRoutine : NetworkBehaviour
private EventInstance CarMovement;
private void Awake()
{
//Debug.LogError("AUDIO MANAGER:");
@@ -39,6 +40,7 @@ public class CarDrivingRoutine : NetworkBehaviour
CarMovement = AudioManager.Instance.CreateInstance(FMODEvents.Instance.BoltCarSimpleDriving); //initialising the variable
CarMovement.setParameterByName("EasyBoltLogic", 0); //"Driving - 0 in FMOD"
CarMovement.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject)); //setting 3d attributes
}
private void Start()
{

View File

@@ -123,7 +123,7 @@ public class KeyboardManager : NetworkBehaviour
void OnEnterPressed()
{
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, gameObject);
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Click, gameObject);
if (_input.Length > 0)
{

View File

@@ -9,7 +9,11 @@ public class FloorButtonVisualizer : MonoBehaviour
public Sprite ActiveSprite;
public bool ActiveState;
private Image buttonImage;
// Start is called before the first frame update
// --- Static tracking for selection change ---
private static FloorButtonVisualizer lastActiveButton = null;
private static bool initialized = false;
void Start()
{
buttonImage = gameObject.GetComponent<Image>();
@@ -19,12 +23,20 @@ public class FloorButtonVisualizer : MonoBehaviour
{
this.ActiveState = true;
buttonImage.sprite = ActiveSprite;
//Debug.Log("Floorbutton of " + gameObject.name + " activated");
// --- Only play hover if selection actually changed ---
if (initialized && lastActiveButton != this)
{
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, gameObject);
}
lastActiveButton = this;
initialized = true;
}
public void Deactivate()
{
this.ActiveState = false;
buttonImage.sprite = InactiveSprite;
//Debug.Log("Floorbutton of " + gameObject.name + " deactivated");
}
}

View File

@@ -25,6 +25,9 @@ public class MenuTeleportButton : MonoBehaviour
private EventInstance TeleportingSound;
FMOD.Studio.Bus SpecialBus; //FMOD bus variable
private static MenuTeleportButton lastSelectedButton = null;
private static bool initialized = false;
private void Awake()
{
TeleportingSound = AudioManager.Instance.CreateInstance(FMODEvents.Instance.Teleport); //initialise the instance
@@ -58,12 +61,19 @@ public class MenuTeleportButton : MonoBehaviour
public void SetStateSelected()
{
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, gameObject);
if (button != null && HoverSprite != null)
{
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);
}
lastSelectedButton = this;
initialized = true;
}
}
public void SetStateDefault()
@@ -106,7 +116,7 @@ public class MenuTeleportButton : MonoBehaviour
button.interactable = false;
button.interactable = true;
StartCoroutine(MuteBusForSeconds(1.5f));
StartCoroutine(MuteBusForSeconds(2.0f));
TeleportingSound.start(); //playing 2d oneshot
}

View File

@@ -14,10 +14,16 @@ public class TutorialAudioListener : MonoBehaviour
private TeleportationProvider teleportationProvider;
private float lastStepTime;
[SerializeField] private float baseStepCooldown = 0.5f; // base interval at speed = 1
private float stepCooldown;
[Header("Settings")]
[SerializeField] private float baseStepRate = 0.5f; // Step interval at joystick = 1 and slider = 1
[SerializeField] private float joystickThreshold = 0.1f; // Minimum stick movement to count as walking
private float settingsSpeedMultiplier = 1f; // From slider (1 = default)
private bool locomotionEnabled = false;
private Vector2 currentMoveVector;
private void Awake()
{
if (tutorialController == null)
@@ -32,14 +38,15 @@ public class TutorialAudioListener : MonoBehaviour
turnAction = tutorialController.turnProvider.rightHandSnapTurnAction.action;
teleportationProvider = tutorialController.teleportProvider;
}
stepCooldown = baseStepCooldown;
}
private void OnEnable()
{
if (moveAction != null)
moveAction.performed += OnMovePerformed;
{
moveAction.performed += OnMoveInput;
moveAction.canceled += OnMoveCanceled;
}
if (turnAction != null)
turnAction.performed += OnTurnPerformed;
@@ -57,7 +64,10 @@ public class TutorialAudioListener : MonoBehaviour
private void OnDisable()
{
if (moveAction != null)
moveAction.performed -= OnMovePerformed;
{
moveAction.performed -= OnMoveInput;
moveAction.canceled -= OnMoveCanceled;
}
if (turnAction != null)
turnAction.performed -= OnTurnPerformed;
@@ -75,26 +85,48 @@ public class TutorialAudioListener : MonoBehaviour
private void HandleLocomotionToggled(bool enabled)
{
locomotionEnabled = enabled;
Debug.Log($"[TutorialAudioListener] Locomotion toggled: {enabled}");
}
private void HandleSpeedChanged(float newSpeed)
{
// Invert proportionality: faster speed = shorter step interval
float calculatedCooldown = baseStepCooldown / Mathf.Max(newSpeed, 0.01f);
// Clamp the result between 0.4 and 0.6 seconds
stepCooldown = Mathf.Clamp(calculatedCooldown, 0.3f, 0.69f);
Debug.Log($"[TutorialAudioListener] Step cooldown adjusted: {stepCooldown}");
// Slider is allowed to range normally but we clamp for stability
settingsSpeedMultiplier = Mathf.Clamp(newSpeed, 0.4f, 1.2f);
}
private void OnMovePerformed(InputAction.CallbackContext context)
private void OnMoveInput(InputAction.CallbackContext ctx)
{
currentMoveVector = ctx.ReadValue<Vector2>();
}
private void OnMoveCanceled(InputAction.CallbackContext ctx)
{
currentMoveVector = Vector2.zero;
}
private void Update()
{
TryPlayStep();
}
private void TryPlayStep()
{
if (!locomotionEnabled)
return;
if (Time.time - lastStepTime < stepCooldown)
float joystickMagnitude = currentMoveVector.magnitude;
if (joystickMagnitude < joystickThreshold)
return; // Not moving enough to walk
// --- NEW: Slider influence (very light touch) ---
float sliderInfluence = 1f + (settingsSpeedMultiplier) * 0.25f;
float effectiveMagnitude = joystickMagnitude * sliderInfluence;
// --- NEW: Step cooldown ---
float dynamicCooldown = baseStepRate / Mathf.Max(effectiveMagnitude, 0.01f);
dynamicCooldown = Mathf.Clamp(dynamicCooldown, 0.33f, 0.65f);
if (Time.time - lastStepTime < dynamicCooldown)
return;
lastStepTime = Time.time;
@@ -103,13 +135,16 @@ public class TutorialAudioListener : MonoBehaviour
private void OnTurnPerformed(InputAction.CallbackContext context)
{
// If magnitude above threshold = walking don't play spin sound
if (currentMoveVector.magnitude > joystickThreshold)
return;
// Otherwise play turning sound
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.StepSpin, gameObject);
}
private void OnTeleportEnd(LocomotionSystem locomotionSystem)
{
// Optional: Uncomment if teleport should play sound
// AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Steps, gameObject);
// Optional teleport sound
}
}

View File

@@ -3221,6 +3221,7 @@ GameObject:
- component: {fileID: 2567477070120516364}
- component: {fileID: 5667922335807455518}
- component: {fileID: 9130699439852735294}
- component: {fileID: 244862221083601452}
m_Layer: 5
m_Name: Level 1 button
m_TagString: Untagged
@@ -3346,6 +3347,35 @@ MonoBehaviour:
InactiveSprite: {fileID: 21300000, guid: 9b9161f51c7cdb84eba98c454b3f542c, type: 3}
ActiveSprite: {fileID: 21300000, guid: 594b1f27343305e4e99551b5fb8a1b76, type: 3}
ActiveState: 0
--- !u!114 &244862221083601452
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4006117569149960393}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0b148fe25e99eb48b9724523833bab1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Delegates:
- eventID: 0
callback:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 9130699439852735294}
m_TargetAssemblyTypeName: FloorButtonVisualizer, Assembly-CSharp
m_MethodName: Activate
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
@@ -3395,6 +3425,7 @@ GameObject:
- component: {fileID: 735405659653074444}
- component: {fileID: 1877344747539671532}
- component: {fileID: 2993125651756248496}
- component: {fileID: 5719623585416982853}
m_Layer: 5
m_Name: Level 2 button
m_TagString: Untagged
@@ -3520,6 +3551,35 @@ MonoBehaviour:
InactiveSprite: {fileID: 21300000, guid: 28748e86c9a1f0c4694006461434eca7, type: 3}
ActiveSprite: {fileID: 21300000, guid: a84b9455a04a3ca459595ecb5810fb98, type: 3}
ActiveState: 1
--- !u!114 &5719623585416982853
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4441188026596657465}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0b148fe25e99eb48b9724523833bab1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Delegates:
- eventID: 0
callback:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2993125651756248496}
m_TargetAssemblyTypeName: FloorButtonVisualizer, Assembly-CSharp
m_MethodName: Activate
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
@@ -7700,7 +7760,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
tutorialController: {fileID: 8296457994299276779}
stepCooldown: 0.4
locomotionConfigurator: {fileID: 0}
baseStepRate: 0.5
joystickThreshold: 0.1
--- !u!4 &4954755430420460766 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 1894017693134941767, guid: d90913a7f0b00844a8c4482b2afc2c66,