# How would I get the center of the surface my ray is hitting on an irregular shape?

How would I go about grabbing the center of a surface my ray is on? This is the last thing I need to complete my placement system. If there’s any confusion, here’s a picture of what I am trying to achieve:

I apologize in advance for the extremely vague post. I am sleep deprived and mentally exhausted so I’m currently on auto pilot trying to wrap my head around this. Figured it’d be quicker to see if any of you have any brilliant ideas before I sit here for way longer than I should. I don’t need a super in-depth explanation, just a little something to give me a lightbulb above my head. I’ve searched all over the forum and haven’t seen anything suiting my needs.

Normally isn’t the pivot of a part positioned at the center? if so you can just do `surface.Position`.

You’ll need to have information about the mesh you’re hitting, which you can’t get from Roblox, so you’d need to create some kind of mesh data parser (.obj, .fbx, etc), I’m really not sure this is a road you want to go down. You can get the normal of the surface you hit from the ray cast, but finding the center point of a face is not something you’ll be able to do without something like what I mentioned above.

Hey, sorry to bump this post but I’ve open sourced a placement system of mine a while ago that is able to work for irregular surface normals, heres the place: Placement System - Open Sourced - Roblox

1 Like

No need to apologize; I appreciate your response! I needed the location of the center of the surface for clamping purposes, as my placement system already snaps to the surfaces in grid increments. I needed the location of the center of irregular surfaces for clamping purposes, as I found a workaround for calculating the size of irregular surfaces, so all that’s left is calculating the position of the center so that I could create a new grid and clamp the part within the bounds using the size data. Unfortunately, it doesn’t seem to be possible (at least until dynamic meshes release) without mapping out the location of each of the exterior faces in separate software and storing that data elsewhere. Funny enough, I had already looked at your placement system prior to your reply and have actually linked a few others having troubles with their own systems to it. While it unfortunately doesn’t suit my needs, it’s a great resource and you did a great job with it.

Thanks again.

Hey, funnily enough I’ve been working on a new placement system and decided to rewrite all of this. I ended up also coming up with a solution for getting the surface center and surface size of any object/mesh this is a video demo of it

Here’s the place file:
SurfaceDetailCalculations.rbxl (57.9 KB)

Unfortunately, yours seems to run into the same issue as mine. It’s pretty buggy when working with faces that are offset and don’t point towards the center of the mesh. Try it with this shape as an example and you’ll see what I mean:

Test Object.obj (58.6 KB)

I appreciate you linking that, I’ll definitely look more into it more tomorrow. I can think of a few quick ways this could be solved, I’m just worried about how practical and performant the methods I’m considering would be for use in a large scale game.

Hey, just wanted to let you know that I was trying to figure this out for my placement system also but was unable to get a consistent result. I hope that you are able to figure this out