I'm currently building a block breaking game without a tutorial. This is the first time I've seriously sat down to building something on my own with Godot.
Things are working as expected until the ball hits the Area2D "deadzone" which sends two signals, one to the paddle and one to the ball.
The issue is, when the ball hits the Area2D, it immediately breaks the left, lowest block. And then it resets. When I relaunch the ball, always relaunched from the position of the broken block.
This is the code that sends the signals on the HUD:
func _on_DeadZone_body_shape_entered(body_id, body, body_shape, area_shape):
if body.name == "Ball":
And here are the bits of code that handle the reset of the ball itself:
should_reset = true
if should_reset == true:
should_reset = false
state.linear_velocity = Vector2()
var t = state.get_transform()
t.origin.x = startingPos.x
t.origin.y = startingPos.y
launched = false
mode = MODE_STATIC
sleeping = true
And these bits of code handle the ball follow and release:
if launched == false:
var followPos = Vector2(paddle.position.x, startingPos.y)
mode = MODE_RIGID
var t = Timer.new()
apply_impulse(Vector2(), Vector2(0,-1).normalized() * ball_speed)
launched = true
I have Staticbody2Ds set up for bumpers on the sides and top (but not the bottom) that only detect the paddle and the ball. Likewise the breakable blocks at the top only detect the ball. The ball itself only detects the paddle.