- Home /
Wierd error messages concerning audio play and pause?
I did a simple script to make the main character in my game 'sprint'. It was working fine, but then I tried to make it so an audio file of heavy breathing would play when the person sprinted, and when they let go of the sprint button and second audio file of slower breathing would play. Here is the script:
var run : AudioClip;
var slow : AudioClip;
function Update() {
var motorScript = transform.GetComponent(CharacterMotor);
if(Input.GetKeyDown("e"))
{
motorScript.movement.maxForwardSpeed = 15;
audio.Play(run);
}
if(Input.GetKeyUp("e"))
{
motorScript.movement.maxForwardSpeed = 6;
audio.Pause(run);
audio.PlayOneShot(slow);
}
}
However, when I compile the script, I get two error messages that I don't understand. One is: "Assets/Game Scripts/sprint.js(13,14): BCE0023: No appropriate version of 'UnityEngine.AudioSource.Play' for the argument list '(UnityEngine.AudioClip)' was found."
The other is : "Assets/Game Scripts/sprint.js(18,15): BCE0017: The best overload for the method 'UnityEngine.AudioSource.Pause()' is not compatible with the argument list '(UnityEngine.AudioClip)'."
What do these messages mean and how do I fix them?
Answer by PAEvenson · Nov 21, 2012 at 09:00 PM
Play doesnt take an audioClip. try:
audio.clip = run;
audio.Play();
and to pause
audio.Pause();
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Script Errors! 2 Answers
base character script errors. Plz Help. 1 Answer
error cs0120 1 Answer
SendMessage setName has no receiver! 1 Answer