# アニメーションイベントを取得できない

**URL:** <https://creatorsforum.live2d.com/t/topic/1959>\
**Category:** 制作の質問やTips紹介\
**Created:** [2023 年 9 月 8 日午前 9:24 UTC](https://creatorsforum.live2d.com/t/topic/1959 "2023-09-08T09:24:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tani](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@Tani](https://creatorsforum.live2d.com/u/Tani)\
**Post date:** [2023 年 9 月 8 日午前 9:24 UTC](https://creatorsforum.live2d.com/t/topic/1959/1 "2023-09-08T09:24:21Z")

</div>

> **[motion3.jsonに設定されたイベントを取得 | SDKチュートリアル | Live2D Manuals & Tutorials](https://docs.live2d.com/cubism-sdk-tutorials/motion-event/)**

サンプル内の「AnimatingKoharu」Prefabに対して記事の通りに行ってみましたがエラーが発生します。

取得したタイミングでエラーを吐いているのでイベント自体はフックできてるようですが、イベント名などその他諸情報を取得できません。

「AnimatingKoharu」には「body」Clipがあるのでそれにイベントを書き込み、記事通りに作成しました。その結果↓  
「  
‘AnimatingKoharu’ AnimationEvent has no function name specified!」  
というエラーが発生します。

---

<div class="post-metadata">

**Author:** ![ono-at-live2d-com](https://sea1.discourse-cdn.com/flex015/user_avatar/creatorsforum.live2d.com/ono-at-live2d-com/32/167_2.png) [@ono-at-live2d-com](https://creatorsforum.live2d.com/u/ono-at-live2d-com)\
**Post date:** [2023 年 9 月 13 日午前 4:27 UTC](https://creatorsforum.live2d.com/t/topic/1959/2 "2023-09-13T04:27:30Z")

</div>

@Tani 様

いつも弊社製品をご愛顧くださり誠にありがとうございます。  
Live2Dスタッフでございます。

イベントを書き込んだとのことですが、Unity上で追加したものでしょうか？

UnityのAnimationEventは、Functionに設定した文字列と同名の関数を呼び出します。  
 ![2023-09-13_12h27_18](https://us1.discourse-cdn.com/flex015/uploads/live2dtest/original/2X/f/f20cd1ba26e7fd3370e8d3e96a9d61b055a1308b.png)

Functionに設定した文字列とイベントを取得する関数名が異なる場合、イベントを取得することができません。  
もしUnity上で手動で追加したのであれば、こちらの文字列が異なっている可能性がありますので、こちらをご確認ください。

ご覧頂いているチュートリアルでは、.motion3.jsonにイベントが設定されていることが前提のものです。  
設定されたイベントをプログラム側でAnimationEventとして追加しており、その際に関数名の文字列をFunctionへ設定しています。

```auto
var animationEvent = new AnimationEvent
{
    time = UserData[i].Time,
    functionName = "UserDataEventListener", // 追加した行
    stringParameter = UserData[i].Value,
};

```

よろしくお願いいたします。
