extends RigidBody2D var speed = 300 var velocity # Called when the node enters the scene tree for the first time. func _ready() -> void: velocity = Vector2(1, -1).normalized() * speed pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. func _physics_process(delta: float) -> void: var collision = move_and_collide(velocity * delta) if collision: var obj = collision.get_collider() if obj.get_parent().is_in_group('Blocks'): print('block') obj.on_bonk() velocity = velocity.bounce(collision.get_normal()) pass func _on_visible_on_screen_notifier_2d_screen_exited() -> void: print('ball gone') queue_free() func _on_body_entered(body: Node) -> void: return # print('bonk') # if body.get_parent().is_in_group('Blocks'): # print('its a block') # body.on_bonk()