So I have a region3 being created with the bounds of mouse.Hit.p to mouse.Hit.p, and I was wondering if there was a way to get a point 1 stud away from mouse.Hit.p inline with the camera like a ray.


local cam = workspace.CurrentCamera
mouse.Move:Connect(function()
	local camPos = cam.CFrame.Position
	local ur = mouse.UnitRay
	local region = Region3.new(mouse.Hit.p, mouse.Hit.p)--this is what the question is about

	print(region.CFrame," SIZE ",region.Size)
	workspace.Part.CFrame=region.CFrame
end)

I used to have a ray solution (worked exactly the same as this, but still doesn't answer my question here), but in a previous question someone told me it would be better to use mouse.Hit.p in this situation, but the problem remains the same.

https://prnt.sc/mc9z1z The gold dot is what happens when I use your solution, Ruben, the camera's CFrame is never in line with the mouse. The gold dot is the center of the region3 btw.

5 comments

0

Is there a reason as to why the cam variable has to be in the Move event listener? It is a constant; it never changes.

0

you seem to just want to add ||| -Camera.CFrame.LookVector * StudsDistance ||| if i understand your question correctly.

0

it is supposed to be outside of it, I just put it inside to let you know what I am working with

0

its in a bigger script and I guess I could just move it out, but I was thinking too hard when I wrote this

0

@RubenKan, so that solution is what I had in mind the first time, but it doesn't work, I'll update my question with a screenshot of what happens when you use that.