Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Monster Footstep Frequency

Discussion in 'Audio & Video' started by miszu, Aug 18, 2015.

  1. miszu

    miszu

    Joined:
    Aug 18, 2015
    Posts:
    8
    So I have a monster and I want to add a sound effect. I have a nice giant footstep (1.25s audio). So here is my design and I have many ideas but I don't know which one would be the best.

    So my design is if the monster is not chasing me, there will be the footstep sound every 1 sec (So you would hear theoretically 2 sounds at the same time for .25s). Now if the monster is chasing you, the footstep sound would be every 0.5s interval.

    My first solution is I add on runtime a audio source on the monster and play the sound. Once the sound finished playing, I delete the audio source.

    Second solution is to add 3 audio sources on the monster and recycle the audio source if one of them is done playing.

    Is one of the solution better or there is a better solution?
     
  2. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    Not sure which is better, but there's no need to delete the Audio Source. It can always be there. Setting the Audio Source's clip to null will do what you want (save on audio memory)?
     
  3. miszu

    miszu

    Joined:
    Aug 18, 2015
    Posts:
    8
    If I don't delete the Audio Source, the game's fps goes down. So I need to clean the Audio Source.