Hello
I have found this script for giving my 2d character sound for when it walks, although it does not have any legs it moves on a ball. I was wanting sound for just when you press the D or A keys, also if there is a way to add a jumping sound for when you press SPACE bar that would be cool as well. Also if anyone knows what I need to add for when the player gets hit that would also be sweet.
Here's the javascript
var audioStepLength = 0.3;
var walkSounds:AudioClip[];
function Start ()
{
var controller : CharacterController = GetComponent(CharacterController);
while (true)
{
if (controller.isGrounded && controller.velocity.magnitude > 0.0)
{
audio.clip = walkSounds[Random.Range(0, walkSounds.length)];
audio.Play();
yield WaitForSeconds(audioStepLength);
}
else
{
yield;
}
}
}
Thanks