Block hierarchy detection? scripting theory

I’m been making a game for some time now, as many of you are. But I have no idea how to execute a function of the game. Reference the image provided
example

  • I’m trying to make a psuedo-block hierarchy. A player will place a controller block. All blocks connected directly to it become its “child” of sorts. If the controller block were to die, all child blocks should break off and any child-of-child blocks should also die, but still remain attach to their parent. IE Robocraft game from Steam.
  • Problem is, IDK how to implement something like this or how i should get started. I could just make everything a child of child and ect, but that would be horribly inefficient with bigger and bigger vehicles.
  • I also am im implementing the weld system built into studio. So, i cant have everything be a child within itself
  • Is there a way to utilize the built in pathfinding service to detect the path the outermost-blocks take to find out how they are connected to the controller block?
    Any advice on how to tackle this problem is greatly appreciated

I’m also looking to make a similar destruction based game and currently, welds seem to be the way to go from my research as you can see the structure here of the weld graph here created using studios auto weld with the new Weld Constraints

As seen the green active welds are all connected to big red “root” block. Moreover there is a recursive function already built in to check if the block has been disconnected via get connected parts.

https://developer.roblox.com/en-us/api-reference/function/BasePart/GetConnectedParts

So yeah I’ll see how this idea goes for now later during development. Hope this helps.

That looks good in theory, but once the block gets bigger and bigger, itd be extremely impractical because every weld would have to be made algorithmically. Maybe I use int objects and increment the number based off the block it is connected by

Hmm, yeah I see your point for handling large amounts of cubes like Robocraft then yeah voxels seem to be the way to go as it should be way more performant to have them as pure data rather than a cube part. Here’s some research I made:

Idea how to manage the high number of instance of cubes:
Robocraft article:

It also helps with the performance, because we don’t have to render every cube (the obscured ones exist as a data point rather than a 3D object) Robocraft can run smoothly on almost any system.

Yeah reading this post makes me realize that you can’t really use the existing pathfinding services as it automatically creates a navmesh in the game world which we can’t really control, I like this quote though:

But yeah either way we have to organize the data of where each block is placed somehow. The weld graph generated looks cool and maybe you can do something from it or you can go purely with voxel data.

I do love the idea of doing a flood fill detection of the root block. However, the person who you reference did a terrible job explaining how it works :(. He was rather vague on flags, IDs, and flood filling where. And how any of this would resolve the issue

Yeah, they didn’t explain it very well. But after watching the video on flood fill, I believe he is just using flood fill :stuck_out_tongue:

This video should explain it well and why we need to label the points or neighbors in order to find if the block is connected to the root block/controller block as you put it to solve your issue.

TBH, I believe Roblox already implemented this using BasePart:GetConnectedParts() internally so maybe we can take advantage of that already if one uses the weld system :+1:.

Let’s try it out and see how it performs?