Landing Sound Not Always Triggering

Using Unity 2021.3.20f1 and FMOD 2.02.13.

This is a weird one, so bear with me as I try my best to explain the situation.

The current game I’m working on is a haunted corn maze, so it’s mostly a flat plane without any jumping or falling. However, there are sporadically-placed bales of hay throughout the maze that the player can climb upon. I’m trying to have minimal controls for this game since I’d like to eventually port it to smartphone apps, so rather than having a climb mechanic, I just increased the player’s step threshold to match the height of the hay bales, they will simply just “step up” on top of the bale.

Now, what I’m trying to add to the game is that when they get down off of the bale, it plays a landing footstep sound. In other games, I did this by detecting in the script if the player was ungrounded in the previous frame, is now grounded in the current frame, and if so then the landing sound should be triggered. This doesn’t work for this example, however, since the step threshold was increased, it’s not reading the player as being ungrounded, just taking a step down.

The way I figured out around this was to add a trigger collider to the hay bale, and when the player exits the collider, that is what triggers the landing sound effect.

Easy enough - but here is where it gets weird.

It only works on two of the sixteen bales of hay - even though the bales are all prefabs that have not been altered, so they all have the same 3d dimensions. I also have them all placed at the same Y coordinate, just the X and Z coordinates differ.

According to the Unity console, the events are being triggered in the script on all of the bales of hay, but for some reason the sound is only playing when stepping off of these two bales - which I have gone over again and again and confirmed that there is nothing different from these bales and the others, aside from the X and Z coordinates.

Here’s the Trigger Exit script:

void OnTriggerExit(Collider col)
    {
        if (col.gameObject.tag == "HayStack")
        {
            StartCoroutine(LandingSoundDelay());
            print("Landing: On Trigger Exit");
        }
    }

IEnumerator LandingSoundDelay()
    {
        yield return new WaitForSeconds(1);

        firstPersonController.PlayLandingSound();
    }

And here’s the PlayLandingSound() function from the First Person Controller Script:

public void PlayLandingSound()
{
    if (Physics.Raycast(playerCamera.transform.position, Vector3.down, out RaycastHit hit, 5, ~playerLayer))
    {
        switch (hit.collider.tag)
        {
            case "Footsteps/Grass":
                FMODUnity.RuntimeManager.PlayOneShot("event:/Player/Footsteps/Landing/GrassLand");
                break;
            case "Footsteps/Dirt":
                FMODUnity.RuntimeManager.PlayOneShot("event:/Player/Footsteps/Landing/DirtLand");
                break;
            case "Footsteps/Leaves":
                FMODUnity.RuntimeManager.PlayOneShot("event:/Player/Footsteps/Landing/LeavesLand");
                break;
            case "Footsteps/Mud":
                FMODUnity.RuntimeManager.PlayOneShot("event:/Player/Footsteps/Landing/MudLand");
                break;
        }
        NextStep = StepCycle + .5f;
        print("Landing: Player Landed on " + hit.collider.tag);
    }
}

Attaching below screenshots of the Unity Console Log - self explanatory, but “Landing - On Trigger Enter” is when the player enters the trigger zone, “On Trigger Exit” is when the player leaves the trigger zone, and “Landing: Player Landed On [Ground Type]” indicates that the landing sound function was triggered to play the FMOD event which correlates with the player’s footsteps - you may notice the last function occurs a second after the exit is triggered, that’s because for testing purposes I triggered the function via a Coroutine with a 1 second delay, but this will obviously not be the case in the final product.

Also attached below are screenshots of each of the FMOD events: one for landing on dirt, one for grass, one for leaves, and one for mud. Also including screenshots of the hay bales in Unity, with their inspector details - bales 3 and 4 are the two that work properly, the rest do not work. I turned the volume nobs all the way up for testing, to ensure that I wasn’t confusing the landing sound with a regular footstep.

Any suggestions would be greatly appreciated!








For further troubleshooting, I tried using a FMOD Event Emitter attached to the object with the trigger collider - even though I know that this wouldn’t work quite as well, since the event emitter can’t detect which ground type the player is landing on and specify which event should be played, I figured it might at least shed some different result…but nope. Same result. The event is playing on the two haystacks that worked before, but none of the others.

Update - I did some more fiddling, and now the event emitter is working on all of the hay bales. Ultimately, I guess I don’t need to have the different ground types for this landing effect, so this will work in the end, if no one has any ideas as to why the scripted method wasn’t working.

Even with the info and screenshots you’ve provided, it’s difficult for me to narrow down what the exact cause of the issue is. To start with, I would recommend doing the following:

There are a few things that could cause the issue on the FMOD side of things, i.e. bus-level instance limits, one-shot events (if they’re being spatialized) at the default one-shot location of (e.g. new Vector3()) being too far away from the listener to be audible, something downstream of the events conditionally muting the signal, etc. Additional info from profiling/logs should help to diagnose it.