- Home /
Footsteps script problem and question
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 ?
$$anonymous$$ake sure you have public before you declare 'var', so it's public var WalkSound : AudioClip[];
Thanks but, that's not make the inspector able to put between 0 and 1 :/ And how to add a run function ? ^^
Hello!
audioStepLength is an integer , you need the float type.
offtopic: Au fait, tu devrais avoir assez de point maintenant pour cloturer la question précédente ;)
Edit: about the run function more information are needed, do you use a character animation or is just first person with one camera?
Hi !!! ^^ Great ;) It's working.
I've a FPC Only camera. I've put the float to 0.65, Want to put a run function @ 0.75. Offtopic : J'ai mis le pouce vert pour ta réponse sur l'ancien topic ;)
Your answer