Quantcast
Channel: Questions in topic: "footsteps"
Viewing all articles
Browse latest Browse all 164

Footsteps script problem and question

$
0
0
Hi everyone, i'm having a little problem with a script. I'm trying to add a running function but I'm affraid I can't. And why I cannot put anything under 1 in the inspector for the audiosteplength ? :| Here he is : var walkSoundsWood : AudioClip[]; var walkSoundsGrass : AudioClip[]; var audioStepLength : int = 0.3; var groundType : int; var isPlayerWalking : boolean; function Update(){ if(Input.GetButton("Horizontal") || Input.GetButton("Vertical")){ isPlayerWalking = true; } else{ isPlayerWalking = false; } } function Start(){ while(true){ if (isPlayerWalking == true && groundType == 1){ AudioSource.PlayClipAtPoint(walkSoundsWood[Random.Range(0, walkSoundsWood.length)], transform.position); yield WaitForSeconds(audioStepLength); } else if ( isPlayerWalking == true && groundType == 2){ AudioSource.PlayClipAtPoint(walkSoundsGrass[Random.Range(0, walkSoundsGrass.length)], transform.position); yield WaitForSeconds(audioStepLength); } else{ yield; } } } function OnTriggerStay(type : Collider){ if (type.tag == "Wood"){ groundType = 1; print("Wood"); } else if (type.tag == "Grass"){ groundType = 2; print("Grass"); } } Thanks by advance :) EDIT : Nobody ?

Viewing all articles
Browse latest Browse all 164

Trending Articles