How do i get the intersection point between 2 parts ?
I want a da hood type gun system and the part should be where the red line is.
How do i get the intersection point between 2 parts ?
I want a da hood type gun system and the part should be where the red line is.
I don’t know if I understood the question correctly, but if I do, I think I’ve also been working on something similar recently.
First, I got the midpoint of the two points using Lerp with a value of 0.5, then used CFrame.lookAt() to position the part so that it’s pointing towards one of the ends. If you want to know how long the part should be, you can simply subtract the two positions and get the magnitude to calculate the distance between them.
position1 = Vector3.new(...)
position2 = Vector3.new(...)
midpoint = position1:Lerp(position2,0.5)
part.CFrame = CFrame.lookAt(midpoint, position2)
part.Size = Vector3.new(1,1,(position2 - position1).Magnitude)
You’re probably looking for BasePart:GetClosestPointOnSurface() or creating a raycast to use RaycastResult.Position
appreciate ur help mate works perfectly
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.