Removing a portion of or splitting a part

Hello! I’m going to give a quick rundown of what I’m trying to do. I am trying to cut a part into multiple parts to remove a portion of that part, I need them to be completely seperate parts, so unions aren’t an option for my use case. If this seems confusing, please refer to the images below;

image

image

I’ve been attempting to do this on my own, but to no avail, any help would be greatly appriciated!

12 Likes

This might be useful:

4 Likes

Sorry, I should’ve mentioned in the op that I need them to be completely seperate, unions aren’t an option for me.
EDIT: Added to the op.

2 Likes

Update: I’ve improved my function to split parts, but its not quite working correctly, sometimes parts will be spaced out or inside of each other, keep in mind this isn’t the removal part, i’d imagine i’d use this function multiple times to do what i mentioned above.

function Split(part,p,axis) -- "p" is how far along the axis to split.
	local partC = part:Clone()
	local op = part.Position
	
	local s1 = part.Size
	local s2 = partC.Size
	print(s1,s2)
	s1 = s1 - (((s1*(Vector3.FromAxis(axis)))/2)+(((Vector3.FromAxis(axis)))*p))
	s2 = s2 - (((s2*(Vector3.FromAxis(axis)))/2)+(((Vector3.FromAxis(axis)))*-p))
	print(s1,s2)
	
	local p1,p2 = part.Position,partC.Position
	
	--p1 = p1 - (p1*(Vector3.FromAxis(axis)))/2
	--p2 = p2 - (p2*(Vector3.FromAxis(axis)))/2
	
	p1 = p1 + (Vector3.FromAxis(axis)*p)/2 + Vector3.FromAxis(axis)*(s1[axis.Name]/2)
	p2 = p1 - Vector3.FromAxis(axis)*s2[axis.Name]
	
	part.Size = absVector(s1)
	partC.Size = absVector(s2)
	part.Position = p1
	partC.Position = p2
	partC.Parent = workspace
	partC.Name = "Part 2" -- used for testing
end
1 Like

This was done with SubtractAsync:

2 Likes

As mentioned before, unions will not work for my use case

I need them to be parts that can be later merged with other parts (not unioned, but instead the parts are resized and repositioned to make it look like they’re 2 different parts when in reality its one part), furthermore I need it to be at least semi-efficient, this will not work.

1 Like

Hi, I was thinking on this question.
As I see in the attached picture,

  1. the parts are not completely separate, the 3x1 part on the left could be splitted into 3 parts (1x1 size)
  2. there are more options to split parts, e.g. 2 pieces of 2x1 and one 1x1 could be an option.
  3. what if a 3rd dimension (y) comes, like you remove 1x1x1 from a 3x2x2 part?

What I would consider:

  1. do you really need the big part? why don’t you use small (1x1x1) blocks from the start?
  2. if there are limited number of possible “big” parts (from which you remove a smaller one), you may use predefined set of parts that will easily replace the original one.
3 Likes

The big part is needed so i don’t have literal millions of parts in the game, it’s the reason for the part merging script i mentioned in an earlier post in the first place,

This is meant for a game that involves players modifying “terrain”, and as such a solution such as this isn’t viable.

"…game that involves players modifying “terrain”

Ok, clear, I hope someone will tell you the trick.
I worked on a similar “minecraft-like” engine, I faced similar questions.

You could fill locally the targeted big part (on mouse hover) with 1x1x1 blocks (invisible, not cancollide), so when you hit with mouse, you will exactly know which one to be removed. Then you can destroy the big part and replace it with the remaining small ones on the server.

But anyway, your world becomes more and more complex as the players destroy big parts and replace them with smaller ones.

1 Like

Here’s a very good thread/post if you havent read it already:


The link of above uses a method that splits a part on all axises but it’s a little “limited” and doesn’t quite allow for complex cut outs so you’ll probably need to utilize wedges/triangles. In other words you have to do some more splitting

5 Likes

This is EXACTLY what I needed! thank you so much!

2 Likes