getcurrentanimatorstateinfo()normalizedtimeでレイヤー番号を指定してモーションが再生中かどうかを知ることが出来ますが?
その時に特定のアニメーションを選択してそのモーションをnormalizedtimeで時間を取得したいです。
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Attack_Mng : MonoBehaviour { private Animator ani; private Animation anition; private GameObject playerChild; private Weapon wp; // Start is called before the first frame update void Start() { playerChild = GameObject.Find("B_R_Hand"); wp = playerChild.GetComponent<Weapon>(); ani = GetComponent<Animator>(); anition = GetComponent<Animation>(); } // Update is called once per frame void Update() { if(Input.GetMouseButtonDown(0) == true ) { ani.SetTrigger("Attack"); } if(ani.GetCurrentAnimatorStateInfo(0).IsName("Attack") == true)////ここのコード // if(anition["Attack1"].normalizedTime > 0.25f) { if(wp.EnemyCol == true) { Debug.Log("ダメージ!!!"); Destroy(wp.del); } } // anition["Attack"].normalizedTime = 0.5f; } private void Hit(float ae) { if(ae >= 0.0 && ae <= 1.0){ Debug.Log("攻撃"); } } }
あなたの回答
tips
プレビュー