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

Errors at really basic command.

Discussion in 'Audio & Video' started by Anon1234, Apr 30, 2015.

  1. Anon1234

    Anon1234

    Joined:
    Feb 17, 2014
    Posts:
    78
    Code (CSharp):
    1. public AudioClip fireSound;
    Declared on top, I haven't dragged the thing yet, but I will as soon as error goes away.
    In middle of Update, after an correct if and all the checked statements that work perfectly.
    Code (CSharp):
    1. GetComponent<AudioSource>().Play(fireSound);
    Producing errors:
    Assets/Scripts/FireBullet.cs(25,53): error CS1502: The best overloaded method match for `UnityEngine.AudioSource.Play(ulong)' has some invalid arguments
    and
    Assets/Scripts/FireBullet.cs(25,53): error CS1503: Argument `#1' cannot convert `UnityEngine.AudioClip' expression to type `ulong'

    Then tried
    Code (CSharp):
    1. audio.GetComponent<AudioSource>().Play(fireSound);
    Assets/Scripts/FireBullet.cs(25,25): error CS0619: `UnityEngine.Component.audio' is obsolete: `Property audio has been deprecated. Use GetComponent<AudioSource>() instead. (UnityUpgradable)'

    Assets/Scripts/FireBullet.cs(25,59): error CS1502: The best overloaded method match for `UnityEngine.AudioSource.Play(ulong)' has some invalid arguments

    and

    Assets/Scripts/FireBullet.cs(25,25): error CS0619: `UnityEngine.Component.audio' is obsolete: `Property audio has been deprecated. Use GetComponent<AudioSource>() instead. (UnityUpgradable)'

    Any help requested please.
     
  2. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,066
  3. Anon1234

    Anon1234

    Joined:
    Feb 17, 2014
    Posts:
    78
    :D, I see what you did there.
     
  4. SteveJ

    SteveJ

    Joined:
    Mar 26, 2010
    Posts:
    3,066
    Just pointing out that I meant that in a joking way. That was the sort of bug you could have looked at for hours and not spotted :)
     
    Anon1234 likes this.