Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Method of checking collision below a block?

I'm trying to make Tetris, and I want it so that if there's a block below a piece, then it stops moving. (.Touched is unreliable, due to corner touching. And yes, I experimented with "center" blocks but .Touched didn't work because the part isn't unanchored, which I can't have.)

2 comments

0

Maybe have a a plate that sets at the bottom of the pieces that dont stretch to the edges. So that they are only touched by the bricks below.

0

yeah that could work

1 answer

✓ Accepted answer

You can use Region3. wiki: https://www.robloxdev.com/api-reference/datatype/Region3. Here is something that should work for a single tetris cube:

local tetrisFigure= workspace.TetrisFigure --change this into the complete model of the falling tetris figure
local cube = tetrisFigure.TetrisCube -- change this into a single (falling) tetris cube in the tetris figure.
local reg = Region3.new(cube.Position-Vector3.new(0,cube.Size.Y+0.1,0),cube.Position-Vector3.new(0,cube.Size.Y+0.1,0))
local parts = game.Workspace:FindPartsInRegion3WithIgnoreList(reg, {tetrisFigure})
if #parts ~= 0 then
	--a part has been found under the cube
	--stop the cube
end

NEGATIVES:

  1. you have to loop it constantly.
  2. you have to do this for every single cube in a complete figure.

POSITIVES:

  1. it has an ignore list, so if there are parts that you want them to fall through, just add it to the list.
  2. For me, region3 is accurate, and I haven't seen a region3 error for no reason at all.

-I haven't tested it, but it should work, if anyone finds an error comment it so I can fix it.

3 comments

0

I don't understand Region3 at all from that link actually

0

And I cant seem to tune it in the right way

0

Nevermind, I fiigured it out!

This discussion is preserved as it was. New answers, comments, and votes are closed.