前提・実現したいこと
通常は静止しているが、スタートボタンが押されると動くfireというGameObjectを作りたい。
発生している問題・エラーメッセージ
色々とネットで調べながらコードを打ったのですが、コードを追加する前と全く同じ挙動をしています。
エラーとしては、
MissingComponentException: There is no 'Animation' attached to the "fire" game object, but a script is trying to access it.
You probably need to add a Animation to the game object "fire". Or your script needs to check if the component is attached before using it.
と出ています。
該当のソースコード
public void StartButton()
{
flag = 1;
timer = 0.0f;
GameObject obj = GameObject.Find("fire");
Animation anim = obj.GetComponent<Animation>();
anim.Play();
}
と書いたのですが一向に動きません。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。