What I display in this clip is how my mouse in 3D is consistently offset from where my actual mouse should be in 3D and gets worse the further I am from my character it seems?
Does anyone have any idea why this could be happening?
FYI: I have tried
Mouse.Hit
Mouse.Target
aswell
function Mouse:GetMouseTarget()
local Character = LocalPlayer.Character
if Character then
local Params = RaycastParams.new()
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.FilterDescendantsInstances = {Character, workspace.Debris}
local Mouse = LocalPlayer:GetMouse()
local MouseLocation = UserInputService:GetMouseLocation()
local Cast = Workspace.CurrentCamera:ViewportPointToRay(Mouse.X, Mouse.Y)
local Ray = Workspace:Raycast(Cast.Origin, Cast.Direction * 2^8, Params)
local TestPart = Instance.new("Part", workspace.Debris)
TestPart.Anchored = true
TestPart.Position = Ray and Ray.Position or Vector3.zero
TestPart.Size = Vector3.one/2
Debris:AddItem(TestPart, 0.1)
return (Ray and Ray.Instance)
end
end
Do you think it could do with the camera system, maybe since due to the camera orientation the direction is inaccurate, if so do you know what I could do about it?
I’ve already tried (Vector3.new(Mouse.X, Mouse.Y) - workspace.CurrentCamera.CFrame.Position).Unit for the direction.
local function point()
local mouse = localPlayer:GetMouse()
local camera = workspace.CurrentCamera
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {localPlayer.Character, workspace.debrisFolder}
raycastParams.IgnoreWater = true
if localPlayer.Character then
local unitRay = camera:ScreenPointToRay(mouse.X, mouse.Y)
local raycastResult = workspace:Raycast(unitRay.Origin, unitRay.Direction * 2^8, raycastParams)
if raycastResult then
local testPart = Instance.new("Part")
testPart.Parent = workspace.debrisFolder
testPart.Anchored = true
testPart.Position = raycastResult and raycastResult.Position or Vector3.zero
testPart.Size = Vector3.one/2
Debris:AddItem(testPart, 0.1)
end
end
end
I’m thinking it has something to do with the field of view distorting something. Perhaps you could try to do something with the field of view and where the players mouse is?