この文書の現在のバージョンと選択したバージョンの差分を表示します。
| 両方とも前のリビジョン 前のリビジョン | |||
| 
                    vci:sample:shooting:no1 [2023/05/09 13:35] pastatto 統合リンク修正  | 
                
                    vci:sample:shooting:no1 [2023/10/03 20:04] (現在) pastatto 非推奨のAPIを書き換えてサンプルの追加  | 
            ||
|---|---|---|---|
| ライン 7: | ライン 7: | ||
| === サンプルデータ === | === サンプルデータ === | ||
| https://virtualcast.jp/products/06f630d669a6d94a9cb061d81aa3ff8d31a540fa06ff65894810903fc97872cf | https://virtualcast.jp/products/06f630d669a6d94a9cb061d81aa3ff8d31a540fa06ff65894810903fc97872cf | ||
| + | |||
| + | {{ :vci:sample:sample_advanced:シューティング.zip |}} | ||
| ===== コンポーネント設定 ===== | ===== コンポーネント設定 ===== | ||
| ライン 15: | ライン 17: | ||
| **赤の弾、赤の銃、赤のマガジン、青の風船**が**2**となるようにします。 | **赤の弾、赤の銃、赤のマガジン、青の風船**が**2**となるようにします。 | ||
| - | {{vci:sample:sample_advanced:tutorial_shooting1.png?400|}} | + | {{vci:sample:sample_advanced:tutorial_shooting1.png?direct&400|}} | 
| - | {{vci:sample:sample_advanced:tutorial_shooting2.png?400|}} | + | {{vci:sample:sample_advanced:tutorial_shooting2.png?direct&400|}} | 
| - | {{vci:sample:sample_advanced:tutorial_shooting3.png?400|}} | + | {{vci:sample:sample_advanced:tutorial_shooting3.png?direct&400|}} | 
| - | {{vci:sample:sample_advanced:tutorial_shooting4.png?400|}} | + | {{vci:sample:sample_advanced:tutorial_shooting4.png?direct&400|}} | 
| - | {{vci:sample:sample_advanced:tutorial_shooting5.png?400|}} | + | {{vci:sample:sample_advanced:tutorial_shooting5.png?direct&400|}} | 
| - | {{vci:sample:sample_advanced:tutorial_shooting6.png?400|}} | + | {{vci:sample:sample_advanced:tutorial_shooting6.png?direct&400|}} | 
| - | {{vci:sample:sample_advanced:tutorial_shooting7.png?400|}} | + | {{vci:sample:sample_advanced:tutorial_shooting7.png?direct&400|}} | 
| - | {{vci:sample:sample_advanced:tutorial_shooting8.png?400|}} | + | {{vci:sample:sample_advanced:tutorial_shooting8.png?direct&400|}} | 
| - | {{vci:sample:sample_advanced:tutorial_shooting9.png?400|}} | + | {{vci:sample:sample_advanced:tutorial_shooting9.png?direct&400|}} | 
| ===== VCIスクリプト ===== | ===== VCIスクリプト ===== | ||
| ライン 40: | ライン 42: | ||
| bullet_B=vci.assets.GetTransform("bullet_B") | bullet_B=vci.assets.GetTransform("bullet_B") | ||
| bullet_R=vci.assets.GetTransform("bullet_R") | bullet_R=vci.assets.GetTransform("bullet_R") | ||
| + | |||
| + | local sound = vci.assets.GetTransform("Sound") | ||
| + | local audioSources = sound.GetAudioSources() | ||
| + | |||
| + | target_B=vci.assets.GetTransform("target_B") | ||
| + | target_R=vci.assets.GetTransform("target_R") | ||
| + | local AnimeB = target_B.GetAnimation() | ||
| + | local AnimeR = target_R.GetAnimation() | ||
| ammo_limit_B=10--残弾 | ammo_limit_B=10--残弾 | ||
| ammo_limit_R=10 | ammo_limit_R=10 | ||
| + | |||
| ---[SubItemの所有権]アイテムにCollider(not Trigger)が接触したときに呼ばれる。 | ---[SubItemの所有権]アイテムにCollider(not Trigger)が接触したときに呼ばれる。 | ||
| ---@param item string @SubItem名 | ---@param item string @SubItem名 | ||
| ライン 49: | ライン 59: | ||
| function onCollisionEnter(item, hit) | function onCollisionEnter(item, hit) | ||
| if (item=="target_B" and hit == "bullet_R") or (item=="bullet_R" and hit=="target_B") then--青風船が割れた | if (item=="target_B" and hit == "bullet_R") or (item=="bullet_R" and hit=="target_B") then--青風船が割れた | ||
| - | vci.assets._ALL_PlayAudioFromName("hit_B") | + | audioSources[1]._ALL_PlayOneShot(1.0) | 
| - | vci.assets._ALL_PlayAnimationFromName("hit_B",false) | + | AnimeB._ALL_PlayFromName("hit_B",false) | 
| elseif (item=="target_R" and hit == "bullet_B") or (item=="bullet_B" and hit=="target_R") then--赤風船が割れた | elseif (item=="target_R" and hit == "bullet_B") or (item=="bullet_B" and hit=="target_R") then--赤風船が割れた | ||
| - | vci.assets._ALL_PlayAudioFromName("hit_R") | + | audioSources[2]._ALL_PlayOneShot(1.0) | 
| - | vci.assets._ALL_PlayAnimationFromName("hit_R",false) | + | AnimeR._ALL_PlayFromName("hit_R",false) | 
| elseif (item=="gun_B" and hit == "ammo_B") or (item=="ammo_B" and hit=="gun_B") then--青リロード | elseif (item=="gun_B" and hit == "ammo_B") or (item=="ammo_B" and hit=="gun_B") then--青リロード | ||
| - | vci.assets._ALL_PlayAudioFromName("reload") | + | audioSources[3]._ALL_PlayOneShot(1.0) | 
| vci.assets.HapticPulseOnGrabbingController(item, 500, 0.3) | vci.assets.HapticPulseOnGrabbingController(item, 500, 0.3) | ||
| ammo_limit_B=10 | ammo_limit_B=10 | ||
| elseif (item=="gun_R" and hit == "ammo_R") or (item=="ammo_R" and hit=="gun_R") then--赤リロード | elseif (item=="gun_R" and hit == "ammo_R") or (item=="ammo_R" and hit=="gun_R") then--赤リロード | ||
| - | vci.assets._ALL_PlayAudioFromName("reload") | + | audioSources[3]._ALL_PlayOneShot(1.0) | 
| vci.assets.HapticPulseOnGrabbingController(item, 500, 0.3) | vci.assets.HapticPulseOnGrabbingController(item, 500, 0.3) | ||
| ammo_limit_R=10 | ammo_limit_R=10 | ||
| end | end | ||
| end | end | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| + | |||
| ---[SubItemの所有権]アイテムをつかんで使うと呼ばれる。 | ---[SubItemの所有権]アイテムをつかんで使うと呼ばれる。 | ||
| ---@param use string @押されたアイテムのSubItem名 | ---@param use string @押されたアイテムのSubItem名 | ||
| ライン 77: | ライン 87: | ||
| if ammo_limit_B>0 then--残弾あり | if ammo_limit_B>0 then--残弾あり | ||
| ammo_limit_B=ammo_limit_B-1 --残弾マイナス1 | ammo_limit_B=ammo_limit_B-1 --残弾マイナス1 | ||
| - | vci.assets._ALL_PlayAudioFromName("shoot") | + | audioSources[5]._ALL_PlayOneShot(1.0) | 
| vci.assets.HapticPulseOnGrabbingController(use, 2000, 0.1) | vci.assets.HapticPulseOnGrabbingController(use, 2000, 0.1) | ||
| bullet_B.SetLocalPosition(gun_B.GetLocalPosition()) | bullet_B.SetLocalPosition(gun_B.GetLocalPosition()) | ||
| ライン 83: | ライン 93: | ||
| bullet_B.SetVelocity(Vector3.zero)--rigitbodyにかかる速度をゼロに | bullet_B.SetVelocity(Vector3.zero)--rigitbodyにかかる速度をゼロに | ||
| bullet_B.SetAngularVelocity(Vector3.zero)--rigitbodyにかかる回転をゼロに | bullet_B.SetAngularVelocity(Vector3.zero)--rigitbodyにかかる回転をゼロに | ||
| + | |||
| local houkou=gun_B.GetForward()--銃の前方 | local houkou=gun_B.GetForward()--銃の前方 | ||
| bullet_B.AddForce(5000*houkou) | bullet_B.AddForce(5000*houkou) | ||
| else--残弾なしのとき | else--残弾なしのとき | ||
| - | vci.assets._ALL_PlayAudioFromName("noammo") | + | audioSources[4]._ALL_PlayOneShot(1.0) | 
| vci.assets.HapticPulseOnGrabbingController(use, 500, 0.05) | vci.assets.HapticPulseOnGrabbingController(use, 500, 0.05) | ||
| end | end | ||
| + | |||
| elseif use=="gun_R" then --赤の銃の処理 | elseif use=="gun_R" then --赤の銃の処理 | ||
| if ammo_limit_R>0 then--残弾あり | if ammo_limit_R>0 then--残弾あり | ||
| ammo_limit_R=ammo_limit_R-1 --残弾マイナス1 | ammo_limit_R=ammo_limit_R-1 --残弾マイナス1 | ||
| - | vci.assets._ALL_PlayAudioFromName("shoot") | + | audioSources[5]._ALL_PlayOneShot(1.0) | 
| vci.assets.HapticPulseOnGrabbingController(use, 2000, 0.1) | vci.assets.HapticPulseOnGrabbingController(use, 2000, 0.1) | ||
| bullet_R.SetLocalPosition(gun_R.GetLocalPosition()) | bullet_R.SetLocalPosition(gun_R.GetLocalPosition()) | ||
| ライン 100: | ライン 110: | ||
| bullet_R.SetVelocity(Vector3.zero)--rigitbodyにかかる速度をゼロに | bullet_R.SetVelocity(Vector3.zero)--rigitbodyにかかる速度をゼロに | ||
| bullet_R.SetAngularVelocity(Vector3.zero)--rigitbodyにかかる回転をゼロに | bullet_R.SetAngularVelocity(Vector3.zero)--rigitbodyにかかる回転をゼロに | ||
| + | |||
| local houkou=gun_R.GetForward()--銃の前方 | local houkou=gun_R.GetForward()--銃の前方 | ||
| bullet_R.AddForce(5000*houkou) | bullet_R.AddForce(5000*houkou) | ||
| else--残弾なしのとき | else--残弾なしのとき | ||
| - | vci.assets._ALL_PlayAudioFromName("noammo") | + | audioSources[4]._ALL_PlayOneShot(1.0) | 
| vci.assets.HapticPulseOnGrabbingController(use, 500, 0.05) | vci.assets.HapticPulseOnGrabbingController(use, 500, 0.05) | ||
| end | end | ||
| + | |||
| elseif use=="target_B" then --ターゲットのリセット青 | elseif use=="target_B" then --ターゲットのリセット青 | ||
| - | vci.assets._ALL_PlayAnimationFromName("reset_B",false) | + | AnimeB._ALL_PlayFromName("reset_B",false) | 
| elseif use=="target_R" then --ターゲットのリセット赤 | elseif use=="target_R" then --ターゲットのリセット赤 | ||
| - | vci.assets._ALL_PlayAnimationFromName("reset_R",false) | + | AnimeR._ALL_PlayFromName("reset_R",false) | 
| end | end | ||
| end | end | ||
| </file> | </file> | ||