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

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,085
  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,085
    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.