~~NOTOC~~ ====== ExportTransform Attachable(装着アイテム) ====== このページは過去の情報となります。\\ 新しいスクリプトリファレンスは**[[https://developer.virtualcast.jp/vci-docs/api/|こちら]]**になります。 [[vci/component/sdk/attachable|装着アイテム]]に対して干渉することができるクラスです。 ^ ExportTransform ^^^ ^ 名前 ^ 説明 ^ バージョン ^ | [[vci/script/reference/attachable#AttachToAvatar]] | 装着可能な場合、装着 | 1.9.2a以降 | | [[vci/script/reference/attachable#DetachFromAvatar]] | 装着している場合、脱着 | 1.9.2a以降 | | [[vci/script/reference/attachable#IsAttached]] | 装着されているかどうか | 1.9.2a以降 | | [[vci/script/reference/attachable#AttachableDistance]] | 装着可能な距離 | 1.9.2a以降 | | [[vci/script/reference/attachable#AttachableHumanBodyBones]] | 装着可能なボーン名一覧(table) | 1.9.2a以降 | | [[vci/script/reference/attachable#GetAttachedPlayer]] | 装着先のプレイヤーのIDを取得 | 2.3.1a以降 | ===== AttachToAvatar ===== **AttachToAvatar fun(): void** 装着可能な場合に、装着を試みます。 SubItemの所有権がない場合は装着できません。 ※次項のサンプルを参照のこと。 ===== DetachFromAvatar ===== **DetachFromAvatar fun(): void** 装着している場合に、脱着します。 === サンプル === local item = vci.assets.GetTransform("Cube") function update() if vci.me.GetButtonInput(1) then print("装着します") item.AttachToAvatar() end if vci.me.GetButtonInput(2) then print("脱着します") item.DetachFromAvatar() end end ===== IsAttached ===== **IsAttached boolean** 装着されている場合に true を返します。 === サンプル === local item = vci.assets.GetTransform("Cube") vci.StartCoroutine( coroutine.create( function() while true do local isAttached = item.IsAttached if isAttached then print("装着しています") else print("装着していません") end sleep(1) end end ) ) function sleep(sec) local t0 = os.time() + sec while os.time() < t0 do coroutine.yield() end end ===== AttachableDistance ===== **AttachableDistance number** 装着可能な距離を返します。 === サンプル === local item = vci.assets.GetTransform("Cube") local dist = item.AttachableDistance print("AttachableDistance: "..dist) ===== AttachableHumanBodyBones ===== **AttachableHumanBodyBones usertype** 装着可能なボーン名一覧をtableで返します。 local item = vci.assets.GetTransform("Cube") print("Bones") local bones = item.AttachableHumanBodyBones for key,value in ipairs(bones) do print(key .. " : " .. value) end ===== GetAttachedPlayer ===== **GetAttachedPlayer fun(): boolean ** 装着先のプレイヤーの ID を取得します。 * 呼び出し元の ExportTransform が装着可能な SubItem を表していない場合、nil を返します。 * 呼び出し元の ExportTransform が装着されていない場合、nil を返します。 * スタジオ/ルームそれぞれで取得できる ID が異なります。 * スタジオでは、ExportAvatar.GetId 相当の ID が返されます。 * ルームでは、ExportRoomPlayer.GetId 相当の ID が返されます。 === サンプル === local cube = vci.assets.GetSubItem("Cube") function update() if not cube.IsAttached then return end local attachedPlayer = cube.GetAttachedPlayer() print("attached to -> "..attachedPlayer) end