Playing multiple sounds using same key input?

Hello all, new to the community it’s a new post so hello everyone. Only recently started c# and unity last month and I’ve hit a problem in my game.
I’m creating a starwars game and have everything working however I can’t seem to figure out how to allow the user play different character sounds.

Now I know how to put an audio in and get that to play when a key is pressed.

How do I let the user press the number 2 key to play one sound then let that finish without any problem and if the user presses the number 2 key again a new sound will happen. Was hoping to get 3-6 sounds to play in a loop.
I’m at work so can’t post my code, but will do when I get home.

Just looking for some advise and help (I’m also new to coding I don’t understand everything ahaha)

Thanks for any help given.

@SozBoss2016

Use a variable (e.g. ‘i’) and every time 2 is clicked, ‘i’ goes up by 1 (i++). Based on ‘i’'s value, a different sound plays. (if i == …) Start it at 0, so that the first click sends it to 1. The first sound should play when ‘i’ is at 1. When ‘i’ reaches the max number of sounds (e.g if i == 6), then play the last sound and reset ‘i’ to 0 (i=0). Hope this helps!

@ollobin
Sorry for the late reply
as soon as I read your answer I all clicked on me. Something so simply :')
if anyone is curious about how to do it heres my following code, hopefully itll help other people :slight_smile:

using UnityEngine;
using System.Collections;

public class VadersNoises : MonoBehaviour {

public AudioSource audio1;
public AudioSource audio2;
public AudioSource audio3;
public float Counter = 0;

// Update is called once per frame
void Update()
{

    if (Input.GetKeyDown(KeyCode.Alpha2))
    {
        if (Counter == 0)
        {
            audio1.Play();
            print("Num 1");

        }

        if (Counter == 1)
        {
            audio1.Stop();
            print("Num 2");
            audio2.Play();

        }

        if (Counter == 2)
        {
            audio2.Stop();
            print("Num 3");
            audio3.Play();
            
        }

        Counter++;
    }

    if (Counter == 3)
    {
        Counter = 0;
    }
}
    
}