Created
November 15, 2022 08:39
-
-
Save makochang/dc21d85117b31ac053074cbc34e942c2 to your computer and use it in GitHub Desktop.
アニメーション残り0.25秒だけ入力を受け付ける
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
using UnityEngine; | |
public class InputTime : MonoBehaviour | |
{ | |
public Animator animator; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
animator = GetComponent<Animator>(); | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
AnimatorClipInfo[] animatorClipInfos = animator.GetCurrentAnimatorClipInfo(0); | |
//ステートのアニメーションの長さ | |
float totalAnimTime = animatorClipInfos[0].clip.length; | |
//現在何秒再生したか | |
float currentAnimTime = totalAnimTime * animator.GetCurrentAnimatorStateInfo(0).normalizedTime; | |
//アニメーションが残り1秒以内なら | |
if (totalAnimTime-currentAnimTime <= 0.25f) | |
{ | |
Debug.Log(animatorClipInfos[0].clip.name + "入力受付"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment