この文書の現在のバージョンと選択したバージョンの差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
vci:sample:ongrab:no1 [2023/05/09 12:45] pastatto 統合リンク修正 |
vci:sample:ongrab:no1 [2023/10/11 17:48] pastatto 概要を編集 |
||
---|---|---|---|
ライン 1: | ライン 1: | ||
- | ====== 風車をつかんだら回りはじめ_放すと止まる ====== | + | ====== 風車をつかんだら回りはじめ、放すと止まる ====== |
- | **onGrab(target)**を使用してオブジェクトをつかむとアニメーションを開始し、\\ | + | **[[https://developer.virtualcast.jp/vci-docs/api/events/onGrab.html | onGrab]]**を使用してオブジェクトをつかむとアニメーションを開始し、\\ |
- | **onUngrab(target)**を使用して手を離すとアニメーションが停止するVCIを作成します。 | + | **[[https://developer.virtualcast.jp/vci-docs/api/events/onUngrab.html | onUngrab]]**を使用して手を離すとアニメーションが停止するVCIを作成します。\\ |
+ | アニメーションの再生には[[https://developer.virtualcast.jp/vci-docs/api/classes/ExportAnimation/PlayFromName.html|PlayFromName]]を使用します。 | ||
+ | |||
+ | 他のサンプル:[[vci/sample/animation/tutorial2]] | ||
=== サンプルデータ === | === サンプルデータ === | ||
https://virtualcast.jp/products/f6415cfeabdd56f12b31ceceb4024d2dd7b45d13ddd82f7a7be55a05d09c7e05 | https://virtualcast.jp/products/f6415cfeabdd56f12b31ceceb4024d2dd7b45d13ddd82f7a7be55a05d09c7e05 | ||
- | ===== オブジェクトの構成 ===== | + | {{ :vci:sample:ongrab:チュートリアルファン.zip |}} |
+ | |||
+ | ==== オブジェクトの構成 ==== | ||
オブジェクトの構成は次のようになっています。 | オブジェクトの構成は次のようになっています。 | ||
- | {{vci:sample:tutorial_fan1.png?400|}} | + | {{ vci:sample:animation:tutorial_fan1.png?direct&600 }} |
- | ===== アニメーション制作 ===== | + | 各オブジェクトのコンポーネントは次のとおりです。\\ |
+ | fan,baseには特に何も追加しません。 | ||
+ | |||
+ | {{ vci:sample:animation:tutorial_fan5.png?direct&600 }} | ||
+ | |||
+ | {{ vci:sample:animation:tutorial_fan6.png?direct&600 }} | ||
+ | |||
+ | ==== アニメーション制作 ==== | ||
ファンが回転するアニメーションが必要なので作成します。\\ | ファンが回転するアニメーションが必要なので作成します。\\ | ||
- | VCI Objectをアタッチする一番上の階層を選択した状態で「Animation」タブの「Create」からアニメーションクリップを生成します。 | + | VCI SubItemをアタッチしたオブジェクト選択した状態で「Animation」タブの「Create」からアニメーションクリップを生成します。 |
アニメーションを作る際に重要な設定がいくつかあります。\\ | アニメーションを作る際に重要な設定がいくつかあります。\\ | ||
この設定を忘れると**アニメーションが動かない**ので確認しましょう。 | この設定を忘れると**アニメーションが動かない**ので確認しましょう。 | ||
- | {{vci:sample:tutorial_fan2.png?400|}} | + | {{ vci:sample:animation:tutorial_fan2.png?direct&600 }} |
- | {{vci:sample:tutorial_fan3.png?400|}} | + | {{ vci:sample:animation:tutorial_fan3.png?direct&600 }} |
- | {{vci:sample:tutorial_fan4.png?400|}} | + | {{ vci:sample:animation:tutorial_fan4.png?direct&600 }} |
- | ===== コンポーネント設定 ===== | ||
- | 各オブジェクトのコンポーネントは次のとおりです。\\ | ||
- | fan,baseには特に何も追加しません。 | ||
- | |||
- | {{vci:sample:tutorial_fan5.png?400|}} | ||
- | |||
- | {{vci:sample:tutorial_fan6.png?400|}} | ||
===== VCIスクリプト ===== | ===== VCIスクリプト ===== | ||
<file lua main.lua> | <file lua main.lua> | ||
- | function onGrab(target)--つかんだとき | + | local transform = vci.assets.GetTransform("fan_root") |
- | vci.assets._ALL_PlayAnimationFromName("fan_rotate_anm",true)--trueにすることでアニメーションをループ | + | local animation = transform.GetAnimation() |
+ | |||
+ | function onGrab(target)--掴んだとき | ||
+ | animation._ALL_Play(true)--trueにすることでアニメーションをループ | ||
end | end | ||
function onUngrab(target)--手を離したとき | function onUngrab(target)--手を離したとき | ||
- | vci.assets._ALL_StopAnimation()--アニメーション停止 | + | animation._ALL_Stop()--アニメーション停止 |
end | end | ||
</file> | </file> | ||