2019-04-29 11:19:28 UNSELECTED

Unknown type code

Copy Copied! Full
ASSET = vci.assets --簡略化 CONTACT_FLG = false --コライダが当たったかどうか vci.state.Set("CONTACT_FLG", CONTACT_FLG) CONTACT_NUM = 0 --BODYのどれに当たったか vci.state.Set("CONTACT_NUM", CONTACT_NUM) NUM = 0 --ドアの移動制御用 first_flg = true --アイテム呼び出したときのみtrue --コライダ名称 BODY = { "Head", "RightArm", "LeftArm", "RightHand", "LeftHand", "Chest", "Hips", "RightThigh", "LeftThigh", "RightToes", "LeftToes", "RightFoot", "LeftFoot", "HandPointMarker" } --BODYに触れたかの判断 BODY_NUM = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } ---アイテムを生成したユーザーで毎フレーム呼ばれる function update() --最初のみ if first_flg == true then PosisionReset() first_flg = false end OBJ = ASSET.GetSubItem("Cube") POS = OBJ.GetPosition() SCAL = OBJ.GetLocalScale() ANG = Vector3.Angle(Vector3.__new(0, 0, 1), OBJ.GetForward()) if OBJ.GetForward().x < 0 then ANG = -1 * ANG end OBJ = ASSET.GetSubItem("side") OBJ.SetPosition(Vector3.__new(POS.x, 2.35 * SCAL.y / 5.4, POS.z)) OBJ.SetRotation(Quaternion.Euler(0, ANG, 0)) OBJ.SetLocalScale(Vector3.__new(1.7 * SCAL.x / 3.4, 0.35 * SCAL.y / 5.4, 0.05 * SCAL.z / 0.2)) Velo_Ang_Zero("side") OBJ = ASSET.GetSubItem("Sphere") OBJ.SetPosition(Vector3.__new(POST.x, 0, POST.z)) OBJ.SetLocalScale(Vector3.__new(4 * SCAL.y / 5.4, 4 * SCAL.y / 5.4, 4 * SCAL.y / 5.4)) Velo_Ang_Zero("Sphere") CONTACT_FLG = vci.state.Get("CONTACT_FLG") if CONTACT_FLG == nil then CONTACT_FLG = false vci.state.Set("CONTACT_FLG", CONTACT_FLG) end --接触があったならば扉の移動量変化 if CONTACT_FLG == true then OBJ = ASSET.GetSubItem("dore2_1") OBJ.SetPosition( Vector3.__new( POS.x - (0 * 0.01 + 0.8) * SCAL.x / 3.4 * math.sin(2 * math.pi * (90 + ANG) / 360), 2 * SCAL.y / 5.4, POS.z - (0 * 0.01 + 0.8) * SCAL.x / 3.4 * math.cos(2 * math.pi * (90 + ANG) / 360) ) ) OBJ.SetRotation(Quaternion.Euler(180, ANG, 0)) OBJ.SetLocalScale(Vector3.__new((95 - NUM * (10 / 75)) * SCAL.x / 3.4, (340 - NUM * (313 / 75))* SCAL.y / 5.4, 0.03 * SCAL.z / 0.2)) Velo_Ang_Zero("dore2_1") OBJ = ASSET.GetSubItem("dore2_2") OBJ.SetPosition( Vector3.__new( POS.x + (0 * 0.01 + 0.8) * SCAL.x / 3.4 * math.sin(2 * math.pi * (90 + ANG) / 360), 2 * SCAL.y / 5.4, POS.z + (0 * 0.01 + 0.8) * SCAL.x / 3.4 * math.cos(2 * math.pi * (90 + ANG) / 360) ) ) OBJ.SetRotation(Quaternion.Euler(180, ANG + 180, 0)) OBJ.SetLocalScale(Vector3.__new((95 - NUM * (10 / 75)) * SCAL.x / 3.4, (340 - NUM * (313 / 75))* SCAL.y / 5.4, 0.03 * SCAL.z / 0.2)) Velo_Ang_Zero("dore2_2") --75フレーム分が動く時間 if NUM < 75 then NUM = NUM + 1 end else OBJ = ASSET.GetSubItem("dore2_1") OBJ.SetPosition( Vector3.__new( POS.x - (0 * 0.01 + 0.8) * SCAL.x / 3.4 * math.sin(2 * math.pi * (90 + ANG) / 360), 2 * SCAL.y / 5.4, POS.z - (0 * 0.01 + 0.8) * SCAL.x / 3.4 * math.cos(2 * math.pi * (90 + ANG) / 360) ) ) OBJ.SetRotation(Quaternion.Euler(180, ANG, 0)) OBJ.SetLocalScale(Vector3.__new((95 - NUM * (10 / 75)) * SCAL.x / 3.4, (340 - NUM * (313 / 75))* SCAL.y / 5.4, 0.03 * SCAL.z / 0.2)) Velo_Ang_Zero("dore2_1") OBJ = ASSET.GetSubItem("dore2_2") OBJ.SetPosition( Vector3.__new( POS.x + (0 * 0.01 + 0.8) * SCAL.x / 3.4 * math.sin(2 * math.pi * (90 + ANG) / 360), 2 * SCAL.y / 5.4, POS.z + (0 * 0.01 + 0.8) * SCAL.x / 3.4 * math.cos(2 * math.pi * (90 + ANG) / 360) ) ) OBJ.SetRotation(Quaternion.Euler(180, ANG + 180, 0)) OBJ.SetLocalScale(Vector3.__new((95 - NUM * (10 / 75)) * SCAL.x / 3.4, (340 - NUM * (313 / 75))* SCAL.y / 5.4, 0.03 * SCAL.z / 0.2)) Velo_Ang_Zero("dore2_2") --若干遅めの移動量 if NUM > 0 then NUM = NUM - 0.5 end end Velo_Ang_Zero("Cube") --コライダが入力されていなかった場合 CONTACT_NUM = vci.state.Get("CONTACT_NUM") if CONTACT_NUM == 0 then --かつ接触していないとなっている CONTACT_FLG = vci.state.Get("CONTACT_FLG") if CONTACT_FLG == false then --BODYで接触部分があれば接触判定にする for i = 1, #BODY_NUM do if BODY_NUM[i] == 1 then CONTACT_FLG = true end end end end end ---@param item string @SubItem名 ---@param hit string @Collider名 function onTriggerEnter(item, hit) if item == "Sphere" then --コライダ触れたかの判断 for i = 1, #BODY do if hit == BODY[i] then CONTACT_FLG = true BODY_NUM[i] = 1 CONTACT_NUM = CONTACT_NUM + 1 --何回コライダの入力があったか vci.state.Set("CONTACT_FLG", CONTACT_FLG) vci.state.Set("CONTACT_NUM", CONTACT_NUM) end end end end ---@param item string @SubItem名 ---@param hit string @Collider名 function onTriggerExit(item, hit) if item == "Sphere" then --コライダ離れたかの判断 for i = 1, #BODY do if hit == BODY[i] then BODY_NUM[i] = 0 CONTACT_NUM = CONTACT_NUM - 1 --何回コライダの入力があったか if CONTACT_NUM < 0 then CONTACT_NUM = 0 end vci.state.Set("CONTACT_FLG", false) vci.state.Set("CONTACT_NUM", CONTACT_NUM) end end end end ---@param item string @SubItem名 ---@param hit string @Collider名 function onCollisionEnter(item, hit) if item == "Sphere" then --コライダ触れたかの判断 for i = 1, #BODY do if hit == BODY[i] then CONTACT_FLG = true BODY_NUM[i] = 1 CONTACT_NUM = CONTACT_NUM + 1 --何回コライダの入力があったか vci.state.Set("CONTACT_FLG", CONTACT_FLG) vci.state.Set("CONTACT_NUM", CONTACT_NUM) end end end end ---@param item string @SubItem名 ---@param hit string @Collider名 function onCollisionExit(item, hit) if item == "Sphere" then --コライダ離れたかの判断 for i = 1, #BODY do if hit == BODY[i] then BODY_NUM[i] = 0 CONTACT_NUM = CONTACT_NUM - 1 --何回コライダの入力があったか if CONTACT_NUM < 0 then CONTACT_NUM = 0 end vci.state.Set("CONTACT_FLG", false) vci.state.Set("CONTACT_NUM", CONTACT_NUM) end end end if item == "Cube" then --透明な拡縮対応SubItem正常位置 PosisionReset() end end ---@param target string @UngrabされたSubItem名 function onUngrab(target) if target == "Cube" then --透明な拡縮対応SubItem正常位置 PosisionReset() end end --角度と力0 function Velo_Ang_Zero(item) OBJ = ASSET.GetSubItem(item) OBJ.SetVelocity(Vector3.__new(0, 0, 0)) OBJ.SetAngularVelocity(Vector3.__new(0, 0, 0)) end --透明な拡縮対応SubItem正常位置 function PosisionReset() OBJS = ASSET.GetSubItem("Cube") SCAL = OBJS.GetLocalScale() ANG = Vector3.Angle(Vector3.__new(0, 0, 1), OBJS.GetForward()) if OBJS.GetForward().x < 0 then ANG = -1 * ANG end ROT = OBJS.getRotation() OBJS.SetRotation(Quaternion.Euler(0, ANG, 0)) POST = OBJS.GetPosition() OBJS.SetPosition(Vector3.__new(POST.x, 0, POST.z)) Velo_Ang_Zero("Cube") end