- Home /
PLEASE Help me with this Audio Issue
How can i get it so that when i have vertical and horizontal movement i play an audio clip.
I have this as my script but the audio is distorted and messed up. What's wrong?
var walkAudio : AudioClip;
var isMoving : boolean = false;
function Update() {
if (Input.GetAxis("Horizontal") || Input.GetAxis("Vertical") )
isMoving = true;
audio.PlayOneShot(walkAudio);
}
That code doesn't distort audio. Have you checked the import settings on the audio file? Is your bitrate correct?
Answer by psycocrusher · Mar 29, 2013 at 09:13 PM
I suggest you put all your audio under one parent group, and then you just call the sound you need.
gameObject.Find("YourAudio").audio.Play();
ughh what do you meaan.. like have a parent game object then few game objects as children in it with their own sounds??
yes, each with their own audio source, or else you will end up with audio all over the place. It's fine for small projects only.
create an empty gameObject, put an audio source on it. drag your audio file in the audio source.
Then call it:
gameObject.Find("YourAudio").audio.Play();
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Audio on Collision code doesn't work? 2 Answers
Change Music When GameObject is Grabbed? 1 Answer
Stuck on this! Please help me out. 1 Answer
Audio on collision is not working? 2 Answers