Hey All ! I am working on a school project but I am an art focused student, so bare with me.
I have this script to play footsteps when our character walks:
public class Walking : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if ( Input.GetButton( "Horizontal" ) || Input.GetButton( "Vertical" ) )
audio.Play();
else if ( !Input.GetButton( "Horizontal" ) && !Input.GetButton( "Vertical" ) && audio.isPlaying )
audio.Stop(); // or Pause()
}
}
I have quite a few questions:
1)It works just fine, however we are using a controller for our game and this only works with the keyboard. I tried GetAxis but that doesn't work.
2) She still has the walking sound when she is jumping in the air. I have seen things about isGrounded, but I haven't found anything in depth enough on an explanation, so I don't understand how to add it to this code.
3) I might need to change the code so that a different noise will play when the character jumps and does other actions, so I have to know how to call on specific audio sounds. Would I do this playing the PlayOneShot (filename here)?
Thank you for any help! Again, I apologize that I am not one versed in codes and scripts.
↧