Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Resolved audioSource.Play(footstepsSound); not working

Discussion in 'Scripting' started by TheTiger9801, Apr 28, 2024.

  1. TheTiger9801

    TheTiger9801

    Joined:
    Apr 26, 2024
    Posts:
    1
    I am making a first person 3D game and adding footstep sound effects for when I am walking. Here is my declarations for the audioSource and audioClip:
    Code (CSharp):
    1. public AudioClip footstepsSound;
    2. public float timeBetween = 0.2f;
    3. public AudioSource audioSource;
    Then I use the the function AudioSoundsFX() to play the sound:
    Code (CSharp):
    1. if(currentHorizontalSpeed > 0.001)
    2. {
    3.     Invoke("AudioSoundsFX", 0.3f);
    4. }
    -note I use Invoke because I want to add a delay so my sounds aren't overlapping everytime AudioSoundsFX is called-
    Here is the AudioSoundsFX function:
    Code (CSharp):
    1. private void AudioSoundsFX()
    2. {
    3.     audioSource.Play(footstepSound);
    4. }
    I am getting the error cannot convert from 'UnityEngine.AudioClip' to 'ulong' for whatever reason even though I am pretty sure that I did everything correctly. My audio is in the AudioClip in the inspector and I have a speaker that plays the sound whenever AudioSoundsFX is called. I have no idea what is going on so any help would be appreciated.
     
  2. zulo3d

    zulo3d

    Joined:
    Feb 18, 2023
    Posts:
    1,083