BARRIER code error.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By THE HELIX

I made the viewport as a barrier / a wall to hold the blocks for a game like candy crush.I used kinematicbody 2D for the blocks and attached the code like this

 var extents
 var screensize
 var pos
 var velocity = Vector2()

 func _ready():
       screensize = get_viewport_rect().size
       extents = $Sprite.get_texture().get_size() / 8
       pos = screensize / 8      

 func _physics_process(delta):
       velocity.y += gravity * delta
       position.y += velocity.y * delta
       move_and_collide(velocity * delta)
       pos += velocity * delta
       if pos.x >= screensize.x - extents.x:
	       pos.x = screensize.x - extents.x
	       velocity.x *= 0
       if pos.x <= extents.x:
	       pos.x = extents.x
	       velocity.x *= 0
       if pos.y >= screensize.y - extents.y:
	       pos.y = screensize.y - extents.y
	       velocity.y *= 0
       if pos.y <= extents.y:
	       pos.y = extents.y
	       velocity.y *= 0

When I execute it the viewport acts as a wall/barrier.But during spawning the blocks are held by the viewport wall.When the lower blocks are cleared the upper blocks do not come in the place of the cleared blocks but stay where they where and comes down only when more blocks fall on them.How can I make the blocks to fall freely without staying where they where when the blocks below them are cleared ?

Hi it me again and I make some research and I find this serie of tutorial I don’t know if you already see it but anyway there the link:Make a macth 3 game like candy crush

thoma | 2019-07-06 16:06