im trying to add a sound to my game. when i hit the ball on the groung i should get a sound
here is my code in javascript :
#pragma strict
var rotationSpeed = 100;
var jumpHeight = 8;
var playOnce = true;
var Hit01 : AudioClip;
private var isFalling = false;
function Update ()
{
//Handle ball rotation
var rotation : float= Input.GetAxis ("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
GetComponent.<Rigidbody>().AddRelativeTorque (Vector3.back * rotation);
if (Input.GetKeyDown (KeyCode.JoystickButton2) && isFalling == false)
{
GetComponent.<Rigidbody>().velocity.y = jumpHeight;
playOnceTrue();
}
isFalling = true;
}
function OnCollisionStay ()
{
if (playOnce == true);
{
var theHit = Random.Range(0,4);
if (theHit == 0)
{var audio: AudioSource = GetComponent.<AudioSource>();
audio.clip = Hit01;
audio.Play();}
}
}
function playOncetrue ()
{
yield WaitForSeconds(0.2);
playOnce = true;
}
im getting a BCE0005: Unknown identifier: ‘playOnceTrue’ error
what should i do ?
plzz help