Good Morning,
First of all, I want to say how much I enjoy the package. For a free asset it has been a very nice drag and drop for play testing.
I am trying to change the foot step sounds.
However, when I add a custom sound that works on every other character, it spams the sound. Checking debug logs, it seems that the Play Sound method is being activated more than once for every footstep. I noticed that your sound files have a brief period of silence before the sound is played.
Is that the only solution you have?
A few fixes I have tried are changing the script to only play a sound if a sound is not already playing. This worked great for walking, but sprinting didn’t work. Here is the code I used in the rightFoot method of FootActions.cs
“` if (!Rfoot.isPlaying)
{
Debug.Log(“Play Sound”);
int ClipIndex = Random.Range(0, LayersSaunds[Index].audio.Count – 1);
Rfoot.clip = LayersSaunds[Index].audio[ClipIndex];
Rfoot.Play();
}“`
My other idea would be to instantiate a new sound object every time the audio is played. That is what I do for multiplayer games but since the method is being called hundreds of times that wouldn’t fix it.
I imagine it has something to do with the IK rig.
Any help would be appreciated
-Nate
P.S There are a lot of spelling errors in the code. Although I do not mind it because I still understand what you are trying to say, I could see this being a turnoff for future customers.
Hello Nate
The sound of feet is played via the Unity Raycast.
Each foot has its own Raycast (Lray,Rray,Gray) , You can add a variable that allows you to change the extent of the foot’s view of the ground via Raycast, which will affect the operation of the foot sounds.
Animation also affects this code, When a player lifts his foot from the ground, sound plays on this foot, If your player does not lift his feet off the ground, the code will not work correctly, so check the animation you used.
We are very sorry for the spelling errors caused by the developer. We will check this and it will be fixed in the next versions.