local localPlayer = vci.vc.room.GetLocalPlayer() local gravity = Vector3.Magnitude(vci.vc.room.GetGravity()) local playerController = localPlayer.GetRoomPlayerController() local handle = vci.assets.GetTransform("GliderHandle") local glindStartedY = 0 local initialPotential = 0 local _grounded = false local prevTime = os.time() function updateAll() if handle.IsAttached == false or handle.IsMine == false then return end -- 最初に足を離したら開始 if _grounded == true and playerController.IsGrounded() == false then initalize() end _grounded = playerController.IsGrounded() if _grounded == true then return end local y = localPlayer.GetPosition().y -- 落下開始地点からの差分 local deltaY = (glindStartedY + initialPotential) - y if deltaY <0 then return end local f = handle.GetForward().normalized -- 落下した分の位置エネルギーがすべて運動エネルギーに変わったとする local t = math.sqrt(2.0 * gravity * deltaY) local next = f * t playerController.SetVelocity(next) end function initalize() -- 落下開始地点 glindStartedY = localPlayer.GetPosition().y local v = Vector3.Magnitude(playerController.GetVelocity()) -- 落下時に初速を持っていたらその分だけ高い位置から開始したとみなす initialPotential = v * v / (gravity * 2.0) end