キャラクターに複数のステージで構成される複雑なアクションを設定したいケースが良くあります。全体のアクションをひとつのステートで処理するかわりに、ステージ別に分けて、それぞれに別のステートを使用すべきです。例えば、キャラクターに、しゃがんで狙いを定め、撃ち、再び立ち上がる、“Trickshot” というアクションを設定するとします。
制御上便利ですが、短所としては、ステートマシンが大きくなり、複雑なアクションがさらに追加されると扱いが難しくなります。エディターの空いたスペースで、ステートのグループを視覚的に分けるだけでシンプルにすることができます。しかし、Mecanim はさらに一歩進んで、ステートマシン図でステートのグループを 1 つの名前のアイテムにたたんでまとめることができるようにしています。これらのまとめられたグループは サブステートマシン と呼ばれます。
サブステートマシンを作成するには Animator Controller ウィンドウの空いたところで右クリックして、コンテキストメニューから Create Sub-State Machine を選びます。サブステートマシンはエディター上で引き伸ばされた六角形のマークで表され、他の通常のステートとは区別されます。
六角形のマークをダブルクリックすると、エディターがクリアされてサブステートマシンがまったく別のステートマシンであるかのように編集できます。ウィンドウの上にあるバーは “パンくずトレイルl” で、どのサブステートマシンが現在編集されているかを示します (サブステートマシンの中に別のサブステートマシンを作成できることに注意してください)。トレイル上でアイテムをクリックすることでエディターが特定のサブステートマシンにフォーカスします。
前述のとおり、サブステートマシンは単にエディターで一群のステートを視覚的に折りたたむ方法なので、サブステートマシンへ遷移するときは、その中のどのステートに接続したいかを選択する必要があります。
サブステートマシンに Up で名前が始まる追加のステートができたことに気づきます。
Up ステートは “外の世界” を意味し、ビューのサブステートマシンを囲む (含む) ステートマシンです。サブステートマシンのステートから Up ステートへの遷移を加えると、外のマシンのステートの 1 つを選択するよう求められます。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.