i need help with my pong game

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Hussain

so im making the ball reset if it touches the collision in my pong game but its not working i did exactly the same code as specified in the video here is the link for it
https://youtu.be/kr1BoEbuveI and my code for resetting the ball :

extends Node

func _on_Left_body_entered(body):
$Ball.position = Vector2(640,360)

func _on_Right_body_entered(body):
$Ball.position = Vector2(640,360)

this might not be what you are looking for, however you should put:

func onLeftbodyentered(body):
    if body.is_in_group('ball')
        $Ball.position = Vector2(640,360)

and add the ball to the ‘ball’ group (in image)

putting ball node in group

Snail0259 | 2021-07-09 06:17

:bust_in_silhouette: Reply From: Cogan

I think the problem might be that you are using apostrophes instead of quotation marks

Nah, that shouldn’t be a problem - gdscript is like python in that regard, as it treats double and single quotation marks the same way - as strings!

Snail0259 | 2021-07-09 20:36