![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | KeksKanone |
Hey I did wite the following code for the ball in a breakout game:
extends KinematicBody2D
export var speed = 200
var movement = Vector2(0, speed)
var can_move = true
func _ready():
position.x = 250
position.y = 470
func _physics_process(delta):
if can_move == true:
var collision_info = move_and_collide(movement * delta)
if collision_info:
if collision_info.collider.name == "Player":
speed = -speed
var diff = collision_info.collider.position.x - position.x
var new_movement = Vector2(-diff * 5, speed)
movement = new_movement
else:
movement = movement.bounce(collision_info.normal)
Now I would like to add a bricks with a collision with the ball, wich get destroyed when they collide with the ball.
So my questions are:
Wich Node should I use for the bricks? and
How can I program the brick to be destroyed when it collides with the ball?
Thank you