Seeing if parts are in a certain arrangement

for example, a hexagon
i don’t even know where to start with something like this

It depends on your specific usecase.
The first thing that comes to my mind is choosing an anchor position and raycasting to see if the detected parts are close to their expected spot.

For example, say you want to detect if someone arranged a square. You would have an anchor point in the center of where you’d expect the square to be. Then, you raycast in all 4 directions of that anchor point to check if the hit parts are in the position you’d expect them to be. If the anchor point was at (0, 0), you’d expect the left part to be at (-1, 0).

There are a ton of other implementations you could do and there are a couple places this implementation fails. The algorithm you’d want ultimately depends on the specific usecase you have for this (e.g. do you expect the arrangement to be in a certain spot, or can the arranegmenet be pretty much anywhere in the workspace etc)

im just going to give my attempt at this thingie
just make a hexagon with parts at each point and make the unanchored part slide towards and lock into it when close :​P

Try to find the very corner of each part, and then delete duplicates, e.g the end of one side and the start of another. Noe, find the angle between the centre point of side A, corner A and side B. Do this for all side, angle side pairs. If the parts are regular and all angles are around 120 degrees, then it is a hexagon. You should probably have a margin of error for angles, but using the angle laws you can essentially guess the general shape they are trying to make.
Hope this helps

just hardcoding the corners seems to be working
(also if you are a badge hunter in the future stalking my devforum posts, there’s your hint :3)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.