Forum rules - please read before posting.

Walk Sound causes Problems during switching of Player-Character

Right now I have a really strange problem.
I got in some sounds for my characters footsteps. They work and sound like intended.
However, as soon as I want to switch to a player character with the footsteps, the game will load for about 2-5 Seconds, until it finally changes the character.
At first I thought this might have been because of the filesize, so I tried it again with a 94 kb big soundfile (basically one step, repeating) but the same problem happens.
The problem also stays with me, if I make a build.

I can only solve the problem, once I delete any walk sound out of the "Walk Sound" field from the characters.

Did anybody else have this kind of problems when switching player characters?

Comments

  • edited November 2016
    Had similar problem. Changing the sound file format worked. There are known bottlenecks with Unity and sound files, so maybe this can help: 

    • Use .ogg for compressed audio. Any other audio format will be stored as uncompressed PCM audio in the published player.
    • Use uncompressed audio for small sound effects. Unity (as of 1.6) decompresses all ogg files on the fly. It pays to have short sound effects played often stored as uncompressed wav or aiff files in order not to spend CPU cycles on uncompressing the audio. Examples of where this matters are rapid gunshots, footsteps and similar.
  • Thanks for your input!
    Sadly it's not working for me. No matter which format I put into the "Walk Sound" slot of the character, it causes the Player: Switch action to take multiple second while it "seems" like it freezes the game.
    As soon as no walk sound is in the slot, it works just fine.
  • edited November 2016
    Is the sound file itself affecting the length of the freeze?  I suspect this is a Unity sound issue, even if the options you've changed to don't affect it yet.

    Are you switching characters for the sole purpose of changing the walk sound?
  • I tried various soundfiles, from 10 second long clips to 0,5 seconds long clips and it seemed like the langth of the sound didn't affect the genght of the freeze. However, as soon as I put in any sound whatsoever into the "Walk Sound" the freeze would happen.

    And sadly no, the switch happens to play a completely different character.

    (My secret hope would be, that I could leave the "Walk Sound" slot empty for the switch, while I'd simply chance the walk sound from nothing to something during gameplay, and change it back to nothing whenever I wanted to switch the character. Also of course to switch the sound of the footsteps.)
  • edited November 2016
    Check the compression type of your sound files. I get the feeling It's most likely something to do with your audio clips, specially if you're the only one reporting the issue. The files may be compressed or it may have something to do with your files' format. 

    Also have this in mind, from Unity's wikia:

    • Use .ogg for compressed audio. Any other audio format will be stored as uncompressed PCM audio in the published player.
    • Use uncompressed audio for small sound effects. Unity (as of 1.6) decompresses all ogg files on the fly. It pays to have short sound effects played often stored as uncompressed wav or aiff files in order not to spend CPU cycles on uncompressing the audio. Examples of where this matters are rapid gunshots, footsteps and similar.
    I'll try to check if there's any "newer" advice for audio types though.
    PS: This Unity answers' post seems interesting too. 
    PS#2: Oh, this blog post is quite good! Take a look!
  • Re-reading my post I now realized that I didn't mention, that I also tried converting it in .ogg, sadly with no effect.
    I'll try the various Load Types tomorrow!

    I just can't wrap my head around the fact that every speech file is called and played correctly (as well as all the sounds in game), without any freezes whatsoever, but the Player-Prefab with a filled in "Walk Sound" slot is making such problems :/
  • edited December 2016
    So I decided (after a lot of trial and error with compressions and loading method) that I am turning on the profiler to see where it is having it's problems.
    I did find a couple of things, but I have NO idea what they want to tell me.

    First, I noticed that really big spike which, of course, was the exact same moment, when the freeze was happening. this spike happens in the CPU usage, as well as in the Audio part of the profiler (and the memory). Apart form that, everything else seems kind of normal, I think.

    (You can watch the bigger screenshots if you right click it and open it in another tab)
    image

    Locating the slider there, showed me that this was indeed unusualy, but luckily I was able to pinpoint it to the very frame where the freeze happened.
    Thank you profiler, I guess.
    image

    So I put on my detective hat and checked out the audio part of the profiler.
    What struck me as "strange" was the fact that there was a sudden increas in "Audio Clip Count" for this one frame. 583 to be exakt (can be seen in the lower left)
    I don't know exactly what it tells me, but maybe it gets called that often in one frame?
    image

    After that I checked out the CPU usage, with Depp Profiling activated. If my guess is correct, I could tell which line of code would use the most of my CPUs power.
    This is where I did some digging and was surprised that I had a lot of calls happening during this one frame.
    image

    I don't know what this all tells me, or what can be a solution for this.
    However I found out that I can have the "Walk Sound" slot filled with a sound file, if the "SFX Sound Child" is empty. Then no freeze happens. But also no walk sound is happening.

    The search continues!


    EDIT:
    It "seems" like that, once I plug in the sound into "Walk Sound" it tries to load everything in the Resource folder, including every speech file, lipsync file and prefabs I have located there.

    This is only my guesswork though, since the numbers don't match up perfectly.
  • edited January 2017
    Big fat thanks to Chris!
    THANKS!

    With the new update (1.55b) it is possible to change "Walk Sounds" via Character: Animate -> Change sound? -> Walk

    I still don't know how or why the bug happened, but having Player prefabs without sounds, and then adding sounds for the new player, while removing sounds from the old player, right after the switch completely gets rid of this problem!

    Thanks again for this feature!
  • Strange, but... if it works, it works!
  • I am 90% sure that it was generated by a user error.
    The project (see game showcases) was made from not knowing where to start, to full blown 20 minute 3D Adventure Game. So there might have been a few things I did wrong, quite frankly.
    And while Adventure Creator is forgiving a lot of times (thanks for that) I assume, once the "not best practices" add up, the result is a hickup once in a while.
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.