Im trying to raycast using 2 attachment positions. Supposedly raycast is asking for 2 vector3.
But. If I supply a position for the second argument, isnt working good. If I (goal - origin).Unit*X. Im getting a little undesired offset.
Whats a good approach to raycast from point to point, in this case Im using some attachments (which is not important, its just two vector3 got from the attachments world coordinates)
Right now my script is a total mess, cause I made lots of experiments… @firsttobebear
So I will write a quick example code, just to show what I want, and Im not getting :v
(raycast seems very simple to use, but I cant make it work between 2 attachments…)
local r1 = game.Workspace.ATT1 -- imagine these both are attachments
local r2 = game.Workspace.ATT2
while true do
ray = workspace.Raycast(r1.WorldPosition, r2.WorldPosition)
print(ray.Instance)
wait(2)
end
I tried different ways to do that simple thing, and the best I got is a little offset of the ray, like 3 studs offset, from the attachment positions.
I just want to see an easy example. The best working thing its just r2.WorldPosition - r1.WorldPosition)Unit*X. But Im having a little offset…
well hold on. maybe I didnt tried worldPosition for both attachments… But, can u just show a little quick dummy example? If I provide 2 vector3 positions based on world coordinates should work? idk why mine is not working…
Like you said, the raycast needs two vector3s given to it for it to work. One of these is the position of the start of the ray and the other is the direction and magnitude of the ray. If you want a ray to cast from one point, P1 to another point, P2 then you’d do:
I made a new baseplate, and test it all, and its working great… The problem was not the raycast… it was just the mess I was doing. Thank you so much! I was the silly one here by doing a common mistake… xD
idk which post to mark as the solution cause all of you were right :3