rbx.lua如何在不点击的情况下找到鼠标的x,y,z(循环)
rbx.lua How to Find the x,y,z of the mouse without clicking (loop)
我一直在寻找一种获取鼠标坐标的方法,这样我就可以将一个部件传送到我的游戏鼠标上。我发现的只是 GetMouse() ,我不太明白。顺便说一句,我是 rolblox lua.
的新手
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
MousePos = Mouse.Hit
print (MousePos)
好吧,首先我假设您的代码是本地脚本(它应该是这样)。 ':GetMouse()' 只是获取玩家的鼠标。鼠标具有不同的属性和事件。
您可以通过以下方式获取鼠标的CFrame:
local MouseCFrame = Mouse.Hit
CFrame 值不仅仅包含鼠标在现实世界中的位置 space。 CFrame 值包含位置和旋转。我们可以通过以下方式获得位置:
local MousePosition = MouseCFrame.p
我们使用 CFrame 值的 'p' 属性 来获取该 CFrame 值的位置。很有用。所以,你的最终代码是:
local Player = game.Players.LocalPlayer -- Also, I noticed you weren't using 'local' to define your variables. Use that, as it sets the variable apart from a global variable.
local Mouse = Player:GetMouse()
local MouseCFrame = Mouse.Hit
local MousePosition = MouseCFrame.p
print (MousePosition)
希望我有所帮助! :)
我一直在寻找一种获取鼠标坐标的方法,这样我就可以将一个部件传送到我的游戏鼠标上。我发现的只是 GetMouse() ,我不太明白。顺便说一句,我是 rolblox lua.
的新手Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
MousePos = Mouse.Hit
print (MousePos)
好吧,首先我假设您的代码是本地脚本(它应该是这样)。 ':GetMouse()' 只是获取玩家的鼠标。鼠标具有不同的属性和事件。
您可以通过以下方式获取鼠标的CFrame:
local MouseCFrame = Mouse.Hit
CFrame 值不仅仅包含鼠标在现实世界中的位置 space。 CFrame 值包含位置和旋转。我们可以通过以下方式获得位置:
local MousePosition = MouseCFrame.p
我们使用 CFrame 值的 'p' 属性 来获取该 CFrame 值的位置。很有用。所以,你的最终代码是:
local Player = game.Players.LocalPlayer -- Also, I noticed you weren't using 'local' to define your variables. Use that, as it sets the variable apart from a global variable.
local Mouse = Player:GetMouse()
local MouseCFrame = Mouse.Hit
local MousePosition = MouseCFrame.p
print (MousePosition)
希望我有所帮助! :)