# Falling tetris like blocks in 2d

Attention Topic was automatically imported from the old Question2Answer platform.
Old Version Published before Godot 3 was released.

I want to create a falling block node, but I’m lost as to what kind of physics body I should use. A straight rigodbody doesn’t make sense, since I don’t want the node moving in the x direction. I’m also utlizing collission reporting to check if neighbor bodies are the same color (if four or more bodies of the same color touch, they disappear).

I tried using a rigidbody set to kinematic, but couldn’t figure out how to move it. This feels like the correct option, but there is little documentation on it.

I could use a kinematic character, but then reporting what it’s colliding with could be a little more work.

Can anyone weigh in on how they would accomplish this? Maybe my whole approach is misinformed.

I think there is a tetris game in the demo’s. Maybe you can have a look at it to see how they implemented it.

theapparatus | 2016-03-21 15:45

I think you should go with now physics at all. I don’t know exactly what you are aiming for, but if you want a tetris like game where blocks fall in increasements than you just could got with a function which makes your collision test and you are fine:

``````func SurroundedBlocks(pos):
surroundingBlocks = []
normal_vectorlist = [Vector2(1,0),Vector2(0,1)]
directions = [1,-1]
for d in directions:
for v in normal_vecorlist:
p = v*d
for block in get_node("parentOfAllBlocks").get_children():
if block.get_pos() == pos:
surroundingBlocks.append(block)
return surroundingBlocks
``````

Than you can check which blocks in that list do have the same color…

You also would need a function to check when the block reached the ground. but this should be easy to get:

``````func onGound(blockGroup): #check if on ground
for b in blockGroup: #you have to check for all teh blocks in one form
for block in get_node("parentOfAllBlocks").get_children():
#chek for all possible colliders
if b.get_pos + Vecor2(0,-1) == pos:
return true #if found one exit functin and return true
return false #if there was nothing in the whole list return false

``````

code could have some mistakes (didn’t test it) so go throu it yourself or ask me if there are problems.