I'm working on creating Pong and I have two RayCast2Ds
on the left and right side of the arena. I have it so whenever one of the RayCast gets hit, the ball resets back to the middle of the arena and the opposite player gets a point. I'm trying to make it so after the ball hits the RayCast, it resets back to the middle of the arena, pauses for 3s and starts the next round. I've added the code inside the if statement for gaining a point but for some reason the timer won't start.
func _physics_process(delta): if $RayCast2D.is_colliding(): if (!already_collided): already_collided = true $Ball.position.x = 575 $Ball.position.y = 350 Globals.p2_score += 1 $Label2.text = str(Globals.p2_score) await get_tree().create_timer(3).timeout #timer else: already_collided = false if $RayCast2D2.is_colliding(): if (!already_collided): already_collided = true $Ball.position.x = 575 $Ball.position.y = 350 Globals.p1_score += 1 $Label.text = str(Globals.p1_score) await get_tree().create_timer(3).timeout #timer else: already_collided = false