- Home /
Question by
epic1legend · Feb 21, 2014 at 07:46 PM ·
beginnerjumping
Unity jumping sound, help.
So I'm trying to make a sidescroller in Unity using 2D. I want my character to make a sound when he jumps. But if I press the jump button again in the air the sound will play but hes not jumping, I don't want this.
Here's my code...
#pragma strict
var jump : AudioClip;
function Update () {
if(Input.GetButtonDown("Jump")){
if(!audio.isPlaying){
audio.Play();
}
}
}
Comment
Answer by Xtro · Feb 21, 2014 at 08:00 PM
use CharacterController.isGrounded
https://docs.unity3d.com/Documentation/ScriptReference/CharacterController-isGrounded.html