この文書の現在のバージョンと選択したバージョンの差分を表示します。
両方とも前のリビジョン 前のリビジョン | |||
vci:sample:oncollision:no1 [2023/09/29 20:25] pastatto 非推奨のAPIを書き換えてサンプルの差し替え |
vci:sample:oncollision:no1 [2023/10/02 20:17] pastatto Audioも非推奨だったためデータ修正 |
||
---|---|---|---|
ライン 79: | ライン 79: | ||
local transform = vci.assets.GetTransform("drum") | local transform = vci.assets.GetTransform("drum") | ||
local animation = transform.GetAnimation() | local animation = transform.GetAnimation() | ||
+ | local audioSources = transform.GetAudioSources() | ||
---[SubItemの所有権]アイテムにCollider(not Trigger)が接触したときに呼ばれる。 | ---[SubItemの所有権]アイテムにCollider(not Trigger)が接触したときに呼ばれる。 | ||
ライン 85: | ライン 86: | ||
function onCollisionEnter(item, hit) | function onCollisionEnter(item, hit) | ||
if (item == "drum" and hit == "stick") or (item == "stick" and hit == "drum") then | if (item == "drum" and hit == "stick") or (item == "stick" and hit == "drum") then | ||
- | vci.assets.audio._ALL_Play("drum_snd", 1.0, false) --サウンドを鳴らす | + | audioSources[1]._ALL_Play(1.0, false) --サウンドを鳴らす |
animation._ALL_Play(false) --アニメーションを再生 true/falseでループのON/OFFを指定 | animation._ALL_Play(false) --アニメーションを再生 true/falseでループのON/OFFを指定 | ||
vci.assets.HapticPulseOnGrabbingController(item, 1500, 0.05) --itemを掴んでいるコントローラを振動させる | vci.assets.HapticPulseOnGrabbingController(item, 1500, 0.05) --itemを掴んでいるコントローラを振動させる |