I’m trying to make a footstep script that has 4 different footstep sounds. One for regular walking, one for srinting, and one for walking and sprinting in water. I’ve never really worked with audio, and I checked out the docs, but I’m still confused. Here’s my script now…
var walking : AudioSource = GetComponent.<AudioSource>();
var sprint : AudioSource = GetComponent.<AudioSource>();
var walkingWater : AudioSource = GetComponent.<AudioSource>();
var sprintWater : AudioSource = GetComponent.<AudioSource>();
private var enter : boolean;
private var exit : boolean;
function Update () {
if(Input.GetAxis("Horizontal") || Input.GetAxis("Vertical") && exit)
{
GetComponent.<AudioSource>().Play("Footsteps 1");
}
if (Input.GetButton("Sprint") && Input.GetAxis("Vertical") > 0.5 && exit)
{
GetComponent.<AudioSource>().Play("Footsteps 1 Sprint");
}
if(Input.GetAxis("Horizontal") || Input.GetAxis("Vertical") && enter)
{
GetComponent.<AudioSource>().Play("Footsteps 2");
}
if (Input.GetButton("Sprint") && Input.GetAxis("Vertical") > 0.5 && enter)
{
GetComponent.<AudioSource>().Play("Footsteps 2 Sprint");
}
}
function OnTriggerEnter (other : Collider){
if (other.gameObject.tag == "Player") {
enter = true;
}
}
//Deactivate the Main function when player is go away from door
function OnTriggerExit (other : Collider){
if (other.gameObject.tag == "Player") {
exit = true;
}
}
But, I get these errors. Not sure why…
Assets/Footsteps.js(12,50): BCE0023: No appropriate version of ‘UnityEngine.AudioSource.Play’ for the argument list ‘(String)’ was found.
Assets/Footsteps.js(17,50): BCE0023: No appropriate version of ‘UnityEngine.AudioSource.Play’ for the
argument list ‘(String)’ was found.
Assets/Footsteps.js(22,50): BCE0023: No appropriate version of ‘UnityEngine.AudioSource.Play’ for the argument list ‘(String)’ was found.
Assets/Footsteps.js(27,50): BCE0023: No appropriate version of ‘UnityEngine.AudioSource.Play’ for the argument list ‘(String)’ was found.
How can I fix this?