- Home /
How can I play audio clips depending on the players movement
If the user is moving forward, I want to play a particular script, likewise if it is moving backwards. What I have so far:
Please post code as text and format it with the 101010 button so people can copy the code when answering ins$$anonymous$$d of retyping it all.
Also, your "question" isn't asking anything. What is the problem? What isn't working, what is happening and how should it work?
After checking the axis, I am not sure why you do Auu.Play() before setting the clip. Anyway, you are on the right path, but as stated this is not really a question, rather a little project for you to do. I highly suggest you take a look at coroutines, what they are, how they work and how to use them.
EDIT: Despite not being very familiar with unity's audio API, I am pretty sure doing GetComponent() for both clips is wrong and they will both get the same audio clip. Remove these lines and since the variables are public, simply drag and drop the audio clip component to the variable in the inspector
Your answer
Follow this Question
Related Questions
One sound gets quieter when other is played? 1 Answer
[Rhytm game] How to spawn on exact time of music? 3 Answers
How Do I Get This To Play Sound? 0 Answers
2nd Audio Clip Not Playing 0 Answers
How to play "audiosource" component in a prefab from script? 0 Answers