0 votes

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:

func _on_HUD_resetBall():
  should_reset = true


func _integrate_forces(state):
  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:

func _physics_process(delta):
  if launched == false:
    var followPos = Vector2(paddle.position.x, startingPos.y)
    if Input.is_action_pressed("launch"):

func ballRelease():
  mode = MODE_RIGID
  var t = Timer.new()
  yield(t, "timeout")

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.

in Engine by (12 points)

Please log in or register to answer this question.

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.