samedi 27 décembre 2014

Sound wont play in Unity

Hi everyone I'm trying to get a walking sound to play when you move with the game. I tried a lot of methods and the simple audio.clip=walkSound and audio.Play, and non of that worked. Any ideas on how to make the sound play?



public float walkSpeed = 5.0f;
public float slowPentaly = 0.5f;
public float gravity = 20.0f;
public float run = 2.0f;
private Vector3 moveDirection = Vector3.zero;
public AudioClip walkSound;

void Start()
{
//transform.position = new Vector3(0,1.7f,0);
}

void OnControllerColliderHit(ControllerColliderHit hit)
{
if (hit.gameObject.tag == "Shard") {
moveDirection *= slowPentaly;
Debug.Log("You are slow");
}
}
void Update()
{
CharacterController controller = GetComponent<CharacterController> ();
if (controller.isGrounded) {
moveDirection = new Vector3(Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical"));
moveDirection = transform.TransformDirection (moveDirection);
moveDirection *= walkSpeed;

if (Input.GetKeyDown(KeyCode.LeftShift))
moveDirection *= run;
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move (moveDirection * Time.deltaTime);

}

}

Aucun commentaire:

Enregistrer un commentaire