Basically all I need to know is how I could move the centered mouse to a specific location via scripts while in first person, kinda like how the player could move their camera around with their mouse.
1: Get the look vector of the camera (i.e. where the player is looking)
2: Get the unit vector of an object you want to aim assist at and the camera’s origin
3: Find the dot product between these two vectors. If it’s within a threshold, snap the player aim to the object, possibly with CFrame.LookAt
By adjusting the dot product to compare to, you can adjust the radius of aim assist.
Alright thanks, I put together this script to test out your method. I believe I did something wrong as I get around the same value at different spots. Could you check out what I did wrong?
local uis = game:GetService('UserInputService')
uis.InputBegan:connect(function(Input, g)
if not g then
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
local dir = workspace.CurrentCamera.CFrame.LookVector
local part = workspace.TestPart.CFrame.LookVector
local camorig = workspace.CurrentCamera.CFrame
local camtopart = (camorig - part).LookVector
local dotprod = camtopart:Dot(dir)
print(dotprod)
end
end
end)
EDIT I was supposed to put part instead of dir when defining dot lol, my bad.