Hi
I was looking to have the game play a walking sound while only on a certain object(s), in this case, a wooden pillar. I wanted to write a script where when the player was on this wooden pillar, the sound would play if he moved around, in this case pressing W.
Heres the script I have so far, feel free to let me know if i was way off or not
If you need any additional info, let me know!
var StepSound : AudioClip;
function OnCollisonEnter(collision : Collision)
{
if (other.tag == "pillar")
{
function Update()
{
if (Input.GetKeyDown (KeyCode.W))
{
audio.clip = StepSound;
audio.Play();
}
if (Input.GetKeyUp (KeyCode.W))
{
audio.Stop();
}
}
}
}