Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Method of checking collision below a block?

Asked by 5 years ago
Edited 5 years ago

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.)

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. BlauKitten 88 — 5y
0
yeah that could work mlgwinners 30 — 5y

1 answer

Log in to vote
1
Answered by
jaschutte 324 Moderation Voter
5 years ago

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.

0
I don't understand Region3 at all from that link actually mlgwinners 30 — 5y
0
And I cant seem to tune it in the right way mlgwinners 30 — 5y
0
Nevermind, I fiigured it out! mlgwinners 30 — 5y
Ad

Answer this question