Hi so,
What i want is music to play whenever the player is moving…
Here is my code.
#pragma strict
var music = false;
function Start () {
}
function Update () {
if(Input.GetKeyDown(KeyCode.W)||Input.GetKeyDown(KeyCode.A)||Input.GetKeyDown(KeyCode.S)||Input.GetKeyDown(KeyCode.D))
{
audio.Play();
}
if(Input.GetKeyUp(KeyCode.W))
{
if(Input.GetKeyUp(KeyCode.A))
{
if(Input.GetKeyUp(KeyCode.S))
{
if(Input.GetKeyUp(KeyCode.D))
{
audio.Stop();
}
}
}
}
The problem i have is that the music restarts everytime the player presses W A S D even when the player is still moving.
I wanted it so when any of thos keys are down the music keeps on playing and when they are ALL UP then it stops.
Thanks