How to get the Vector3 Position for a part's vertex?

Pretty straighforward, let’s imagine that I wanna create my own custom function of creating a part using 2 parts, one as the starting point and the other one as the ending point. I don’t wanna use Region3.new() to make it.
image
The arrow pointing at that vertex, I wanna get it’s positional Vector3 position, how can I get it? I remember there is a formula but I forgot what it is.

Send help!

Is there any specific vertex you want?

Hmm I’m pretty sure this is the formula of getting a vertex (If you want another vertex you may need to switch some + with -:

local part = game.Workspace.Part --testing purposes
local partPos = part.Position
local vertexPos = Vector3.new(part.Position.X + part.Size.X/2, part.Position.Y + part.Size.Y/2, part.Position.Z + part.Size.Z/2)
local newpart = Instance.new("Part") --for testing purposes, we are gonna place a new part to the vertex position
newpart.Size = Vector3.new(1, 1, 1)
newpart.Parent = game.Workspace
newpart.Position = vertexPos
newpart.Anchored = true --In case it will fall

Tell me if this works
EDIT: Actually it works and starts directly on the vertex I was just a bit dum and forgot to turn off cancollide for the new part

the idea of that is correct but you should use cframe for rotation aswell

1 Like

you could use an attachment instead of creating an entire new part

i said for testing purposes :confused:

local Part = workspace.Part
local BottomLeft = Part.CFrame * CFrame.new(Part.Size.X/2,Part.Size.Y/2,-Part.Size.Z/2) 

This would get the bottom left corner relative to the CFrame.(Which is what you want I guess from the picture given)

1 Like

Great, but why are we diving each of the axes of the part’s size by 2? And why are we multiplying the current part’s CFrame as well?

I don’t care any vertex, all I want is just get one vertex position of a part.

probably the cleanest code wise (less values everywhere and honestly better code practice) would be

local function VertexToWorldPosition(part,cornerVector)
   return part.CFrame*(part.Size/2*cornerVector)
end

input corner vector would be a

Vector3.new(1--[[negative 1 is left, positive is right]],1--[[negative 1 is bottom, positive is top]],1--[[negative 1 is front, positive is back]])

type value

1 Like

image
In the picture here red dot is the centre of the part where the CFrame’s position is, orange is the X offset , green is the Y offset and blue is the Z offset , if u notice the offset are half of the original axes , so you have to multiply the current CFrame by the offset to get the corner

just make sure each of the values are negative or positive one, unless you want to find the face position of a part in which case you would give it the input of

Vector3.new(1,0,0) --right face position
Vector3.new(0,1,0) --top face position
Vector3.new(0,0,-1) --in this example it would give you the front face world position, make sure the value is negative or it will give you the back side

Maybe I just don’t understand the second part that well since I haven’t learn about matrices yet. Thanks for the help.

@Shm_kle thanks for the help as well.

cframe matrixies become a very important and useful tool for higher level stuff. they’ll make sense once you watch a video or two.

Yeah, I mean I’m only 15 years old but my school hasn’t touch about this topic yet until the next or 2 years.