Forum begins after the advertisement:


[part 9] sound design questions

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity [part 9] sound design questions

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #14107
    Anuk Thotawatta
    Level 5
    Participant
    Helpful?
    Up
    0
    ::

    How can i add looping sounds for foot steps and wall-slide. Using audioSource.PlayOneShot(footsteps); in Move() function sounded buggy and it plays even when im standing still

    #14109
    Anuk Thotawatta
    Level 5
    Participant
    Helpful?
    Up
    0
    ::
    <code> private void Move()
        {
    
            rb.velocity = new Vector2(walkSpeed * xAxis, rb.velocity.y);
            anim.SetBool("Walking", rb.velocity.x != 0 && Grounded());
            if(Grounded()){
                audioSource.PlayOneShot(walkSound);
            }
    
        }</code>

    why does it sound like this?

    View post on imgur.com
    #14125
    Joseph Tang
    Level 13
    Moderator
    Helpful?
    Up
    0
    ::

    If you want to play SFX, It’s better to find method’s that you know will only be fired under the circumstances that you want.

    What i mean by that is, if you want a walking SFX, you should put your play audio under an if statement for a bool that’s checking if you are currently moving on the ground, or simply use the getaxisraw horizontal && grounded for the if parameter.

    Then, you want to stop the sound clip from replaying, currently you have your clip on a Update(), so it will replay every frame instead of looping. What you might want to do is have an if statement check if your !audiosource.isplaying. Or a better scenario is to set up a bool specifically for walking since the former solution can be messed up by your character playing other sounds.

    Take a look at this https://forum.unity.com/threads/unity-footstep-sound.921104/ for some tips on how you can set up your sound the way you want.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: