How are region3's calculated?

I’m trying to use Region3’s for my bomb, but right now I’m having an issue with calculating the region3 to make a square around the bomb so that when it explodes, it catches parts in the region3’s radius.

The issue with that is, every time I try to calculate it, the size for it is always off… Even though I set the dimensions for the Classic Bomb’s blast radius in my game to (12, 10, 12), it for some reason makes it 24, 11, 24…

Is there something I’m doing wrong with calculating the region3?

	local region3 = Region3.new(
		bomb.Position - Vector3.new(blastRegion3L, 1, blastRegion3W),
		bomb.Position + Vector3.new(blastRegion3L, blastRegion3H, blastRegion3W) -- Makes a square that is 5x5 long and wide, and 10 studs high (hence the 1 to 10)
	) -- Creates a region3 that destroys any parts in the explosions radius.
1 Like

you need to divide the size by 2 (i’m pretty sure size is Vector3.new(blastRegion3L, 1, blastRegion3W)) because the position is located in the middle.

1 Like

I divided it by 2 and it ended up fixing it but why does this happen and why does dividng it by 2 fix it?

it works simply because the position is located at the middle. if the position was located at the sides, we would not divide by 2.

additionally, the middle is like a “dividing point” of a line (the line represents the size), logically we would be left with 2 separated equal pieces of “line”. using more logic dividing by 2 will give us only the length of 1 piece of line, which we need since the point is at the middle.

To imagine why, you can think of a simple example using a square since a cube is just a square with an extended coordinate axis. Then, we think about just one coordinate, X, since it will be the same for Y as well.

If you have a square, it is as long as its size’s X coordinate right? Imagine you start from the far middle left of the square and you go halfway. That would be X divided by 2. To get to the other end, it’s another X/2 ( do + X/2 to go forward, - X/2 to go backwards).

In our case, we start at the center, we don’t need to go X/2 2 times because that would just be X. We need to go X/2 once only. Apply this to Y and Z.

(just to build from @PerceptualReality’s reply but his answer is just as good)

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