Created
February 5, 2017 14:55
-
-
Save kenjiSpecial/c20ac6d6f8de378d9deb30d4293187d0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| public class HandController : MonoBehaviour { | |
| public Animator anim; | |
| // Use this for initialization | |
| void Start () { | |
| anim = GetComponent<Animator>(); | |
| } | |
| // Update is called once per frame | |
| void Update () { | |
| AnimatorStateInfo currentState = anim.GetCurrentAnimatorStateInfo(0); | |
| float playbackTime = currentState.normalizedTime; // % 1; | |
| float rate = 0f; | |
| if(currentState.IsName("Normal")) { | |
| rate = 0f; | |
| } | |
| if (currentState.IsName("Grab_001")) { | |
| if (playbackTime > 1.0f) rate = 0.0f; | |
| else { | |
| rate = 1.0f - playbackTime; | |
| } | |
| } | |
| if (currentState.IsName("Grab_002")) { | |
| if (playbackTime > 1.0f) rate = 0.0f; | |
| else { | |
| rate = 1.0f - playbackTime; | |
| } | |
| } | |
| if (Input.GetMouseButtonDown(0)) { | |
| anim.Play("Grab_001", -1, rate); | |
| } | |
| if (Input.GetMouseButtonUp(0)){ | |
| anim.Play("Grab_002", -1, rate); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment