Unity3D

アニメーション起動中のみ攻撃判定を表示する

GetAnimationInfo.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GetAnimationInfo : MonoBehaviour {

    public GameObject obj;
    private AnimatorStateInfo stateInfo;
    private Animator anim;

    // Use this for initialization
    void Start () {
        anim = GetComponent<Animator> ();
    }

    // Update is called once per frame
    void Update () {

        stateInfo = anim.GetCurrentAnimatorStateInfo (0);
        if(stateInfo.IsName("Base Layer.アニメーションの名前")){
            obj.SetActive (true);
        }else{
            obj.SetActive(false);
        }

    }
}