- Home /
Question by
Ascend_Dark · Jul 05, 2015 at 10:32 AM ·
Help With Sprinting Audio
I followed a tutorial in C# and i mainly have knowledge in Javascript and i would like to know how i would add a sprinting mechanic to the script below using UnityEngine; using System.Collections;
public class footStep : MonoBehaviour {
public AudioClip[] footsteps;
public float nextFoot;
IEnumerator Start ()
{
CharacterController controller = GetComponent<CharacterController>();
while(true){
if(controller.isGrounded && controller.velocity.magnitude > 0.3F){
audio.PlayOneShot (footsteps[Random.Range(0, footsteps.Length)]);
yield return new WaitForSeconds(nextFoot);
}else{
yield return 0;
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Unity freezes whenever I edit animations. 1 Answer
System.Collections error while building the player for windows phone 8 1 Answer
Crashing of unity 0 Answers
Need help to earn Krama 2 Answers
Help! My script wont work! 1 Answer