Topic was automatically imported from the old Question2Answer platform.
Asked By
Shlopynoobnoob
I put the 2d circle in an area2d node, and I assigned to it this script:
extends Area2D
var screen_size
var direction = Vector2(1.0, 0.0)
var ball_speed = 89
func _ready():
screen_size = get_viewport_rect().size
func _process(delta):
var ball_pos = .get_transform().get_origin()
ball_pos += direction * ball_speed * delta
if ((ball_pos.x < 0 and direction.x < 0) or (ball_pos.x > screen_size.x and direction.x > 0)):
direction.x = -direction.x