Diffrence between Audiosource playclipatpoint and playoneshot

Like this code
AudioSource.PlayClipAtPoint(mHitsSounds[Random.Range(0, mHitsSounds.Count)], transform.position, 1.0f);
its doing a shot sound
if a change to
AudioSource.PlayOneShot(mHitsSounds[Random.Range(0, mHitsSounds.Count)], transform.position, 1.0f);
What will happen ?

  • PlayOneShot() is an instance method that you can call on an existing AudioSource component to play a given audioclip. The clip is played at the position of whatever object the AudioSource component is attached to.
  • PlayClipAtPoint() is a static method of the AudioSource class you can use to create an AudioSource component at a given position and use it to play a given audioclip (and then immediately destroy the audiosource again).

The answer to the question “What will happen?” is that you’ll get an error, because your code is wrong - PlayOneShot does not take the same parameters as PlayClipAtPoint, and PlayClipAtPoint needs to be called on an instance of the AudioSource class.

The answer to the question “Why no answers” is probably because this information is readily available in the documentation: Unity - Scripting API: AudioSource