failing to detect COLLISSION in godot.

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

I need to make the viewport as a barrier / a wall to hold the blocks which are falling along the y-axis from above.I put four staticbody 2D with collission shape around the viewport to create a barrier.

Here is the project Project . Now if you press the numbers they are cleared.If you change velocity. x = 0 and velocity. y = 0 in the circle script the circle do not come down on clearing lower circles.If you change velocity. x = 1 and velocity. y = 1 the circles go through the static body.You can see it by not clicking on the circles and click on them when more circles fall on them. When you put velocity = 1 the circles merge with each other and circles on bottom fall of when circles above them increase.You can see the circles passing through static body if you make visible collision on , Press on the circles after few moments of the circles falling down
Can you please help me solve it ?

:bust_in_silhouette: Reply From: flurick

Wow that is hypnotic.
But anyways, yes, I recognize this! Things fall through the floor if the velocity keeps increasing by gravity even when the object has already landed on the floor, so when the “velocity” is a bigger number then the floor is deep, the collision checking only check if the space under the floor is empty and goes there.

You can draw this on sceen with this in the Cricle.gd and calling update() on the process function:

func _draw():
	draw_line( Vector2.ZERO, velocity, Color.beige) 

I added the draw function and saw that when the line touches the bottom of screen the blocks stop coming down.
As I am new in coding ; What should I do to prevent the blocks from falling through the collission body ?

THE HELIX | 2019-09-04 17:31