Created
October 8, 2014 03:34
-
-
Save rbreve/0cbd9a7c7bb3a935f058 to your computer and use it in GitHub Desktop.
Unity3D animator play once
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IEnumerator PlayOneShot ( string paramName ) | |
{ | |
anim.SetBool( paramName, true ); | |
yield return new WaitForSeconds (anim.GetCurrentAnimatorStateInfo(0).length/2); | |
anim.SetBool( paramName, false ); | |
} | |
// Use this for initialization | |
void Start () { | |
anim = GetComponent<Animator>(); | |
wstate = Animator.StringToHash("Base Layer.walking"); | |
} | |
// Update is called once per frame | |
void Update () { | |
if(Input.GetKeyDown(KeyCode.Space)){ | |
StartCoroutine( PlayOneShot("isKicking") ); | |
//anim.SetBool("isKicking", true); | |
Debug.Log ("kick"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment