📜  roblox 3d 中的光标位置 - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:04.146000             🧑  作者: Mango

代码示例1
local Players = game:GetService("Players")
local Camera = workspace.CurrentCamera
function GetMousePoint(X, Y)
    local RayMag1 = Camera:ScreenPointToRay(X, Y) --Hence the var name, the magnitude of this is 1.
    local NewRay = Ray.new(RayMag1.Origin, RayMag1.Direction * 1000)
    local Target, Position = workspace:FindPartOnRay(NewRay, Players.LocalPlayer.Character)
    return Position
end

--Listen to UserInputService's "InputChanged" event, and get the 
--Position property of the InputObject, which will be a Vector3. Pass X and Y into the
--function. It will return a position in the 3D world.