0 votes

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 ?

in Engine by (140 points)

1 Answer

0 votes

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) 
by (911 points)

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 ?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.