AudioSource.PlayClipAtPoint Manual     Reference     Scripting  
Scripting > Runtime Classes > AudioSource
AudioSource.PlayClipAtPoint

static function PlayClipAtPoint (clip : AudioClip, position : Vector3, volume : float = 1.0F) : void

Description

Plays the clip at position. Automatically cleans up the audio source after it has finished playing.

JavaScript
@script RequireComponent(AudioSource)
// Plays the clip at position
public var clip : AudioClip; //make sure you assign an actual clip here in the inspector
function Start(){
audio.PlayClipAtPoint(clip, Vector3 (5, 1, 2));
}

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(AudioSource))]
public class example : MonoBehaviour {
public AudioClip clip;
void Start() {
audio.PlayClipAtPoint(clip, new Vector3(5, 1, 2));
}
}

import UnityEngine
import System.Collections

[RequireComponent(AudioSource)]
class example(MonoBehaviour):

public clip as AudioClip

def Start():
audio.PlayClipAtPoint(clip, Vector3(5, 1, 2))