Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to create a part between two points?

Asked by
Scaii_0 145
5 years ago

When I say between two points I mean two positions in the map, so the part wont 'fill in' but rather stretch from this position to this one. Is this possible?

Say for example:

pos1 = game.Workspace.Pos1.Value
pos2 = game.Workspace.Pos2.Value
part = Instance.new("Part")
--Part front at pos1 and back and pos2
0
RayCasting. valchip 789 — 5y
0
Will look into it... Scaii_0 145 — 5y
0
This is just a geometry problem if you want the part between two points in space that you already have the coordinates of. You only need raycasting if you have to first find points on the surfaces of irregular parts (parts like mesh or csg for which there is no simple calculation to get the surface points) EmilyBendsSpace 1025 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
local v = (pos1 - pos2)
part.CFrame = CFrame.new(pos2 + 0.5*v, pos1)
part.Size = Vector3.new(part.Size.X, part.Size.Y,v.Magnitude)

Note that because this uses the 2-vector CFrame constructor,you'll get an arbitrary part orientation if pos1 is almost directly above or below pos2, and you'll need to supply more information if you need the part oriented a particular way in this case.

Ad

Answer this question