Forum rules - please read before posting.

Bug in FootstepSounds.cs in 1.82.1?

Hi Chris

I've been looking at why my footstep sounds were always the same volume, regardless of the volume set on the sound child specified in the footstep sounds component, and I think I've found a bug.

I have the Footstep Sounds component set to play from the Footstep Sound Child gameobject. The Relative volume on the Sound component on that object is ignored.

When I debugged line 283 of the FootstepSound.cs file, to see what the volume was being set to, etc. I noticed that the SoundToPlayFrom variable was set to the wrong sound child, despite being set correctly in the inspector.

Can you recreate that?

Here are the screenshots.
https://imgur.com/a/zWXGFHK

You can see in those screenshots that the debug log returns the name of the wrong sound controller. The correct sound controller ("Footsteps Sound Child") never has a clip assigned but the incorrect one ("Sound Child") does get the clip updated by the Footstep Sound component, despite not being shown in the Sound To Play From variable in the inspector.

Make sense?

Olly

Comments

  • Good spot.

    Up at the top of the script is the Awake function. Replace:

    if (soundToPlayFrom)
    

    with:

    if (soundToPlayFrom == null)
    

    Does that resolve it?

  • Not really. What seems to happen then is that audioSource is then never set on line 87, leaving it Null. This means that the null check on line 89 triggers, but can't assign an audiosource to audioSource as there isn't an Audio Source component on the Player root object. A null audioSource then prevents the PlayFootstep() function from playing anything.

    This is seen in the inspector at run time, the FootStep Sound Child never has a clip assigned and no sound is produced when walking.

  • Yes, I was premature with that fix, sorry.

    Instead, go to line 283:

    soundToPlayFrom.audioSource.PlayOneShot (clip, localVolume);
    

    And replace with:

    soundToPlayFrom.audioSource.PlayOneShot (clip, localVolume * soundToPlayFrom.relativeVolume);
    

    What is the result then?

  • Chris, I'm so sorry. I think this was me.

    For some reason I had multiple Footstep controllers within my player prefab. My debugs were flagging up the right info, but on the wrong components.

    I've removed the errant components and it appears to work fine.

    So sorry.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.