Errors at really basic command.

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.

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

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() 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() instead. (UnityUpgradable)’

Any help requested please.

RTFM… :slight_smile:

What you’re probably meaning to use is PlayOneShot:

:smile:, I see what you did there.

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 :slight_smile:

1 Like