Orientation of faces?

Hi. I’ve been wondering, is there a way to obtain the orientation of individual faces? I’m making a placement system, where the object can attach to any surface you click. Things like cubes are easy, but cylinders and unions make this more complicated. I thought if I can get the orientation of the face, I can rotate the object to match that. Any advice here? Thanks

I don’t believe this is possible since there are only 6 faces to every object: NormalId | Roblox Creator Documentation

Not sure if you can, however you could manually define them by adding a part or something to it and using the part to define it’s face. Kinda sucky but it should work theoredically, who knows, probably a better answer somewhere else haha.

You could raycast to see which face is touching the object, then rotate it with that info. You’d have to do the math on the rotation, the faces would only help decide what to set it at.

Could you explain what you mean a little bit more? What your asking is probably possible, but I’m not sure what you’re asking.

You can get the surface that the mouse is pointing at with Mouse | Roblox Creator Documentation.

You could figure out the world rotation of that with

local surface = mouse.TargetSurface
local surfaceObjectNormal = Vector3.FromNormalId(surface)
local surfaceWorldNormal = mouse.Target.CFrame:VectorToWorldSpace(surfaceObjectNormal)

That would work for the six faces of the cube. Not sure how TargetSurface works with cylinders and such.

Or you can WorldRoot | Roblox Creator Documentation with the data from Mouse.UnitRay and determine the normal of the mouse’s position from the RaycastResult | Roblox Creator Documentation.


Thanks, I did not know about “NormalId”, but how would I calculate the orientation on a cylinder?

1 Like

Can you explain what you mean by “the orientation on a cylinder”?

Will a cylinder is made of lots of small long rectangles, so how would I get the orientation of each individual face?

You mean the orientation of the face that the mouse is pointing at? I mentioned that in my first post:

I’m still not sure what you mean, though. What inputs do you have, and what outputs do you want?

I want input of the mouse, and I want to receive the orientation of the face it hits

It can’t be done since the maximum faces under normalId is 6.

I am sure that’s not what he meant . U can use raycast to get the surface normals

This is what i think he is referring to:

Not this:

However according to Roblox image 2 is more likely to happen since there are only 6 surface normals.

Image 2 is the result of not using raycast to calculate face normals. Image 1 WILL surely happen when u are using raycast to calculate normals

1 Like

Sorry, I thought they were talking about NormalId and not Normal (which has little to no documentation)

lol i can relate i am still confused with normals too

1 Like