0 votes

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 onLeftbodyentered(body):
$Ball.position = Vector2(640,360)

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

Godot version i use the latest
in Engine by (12 points)

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

1 Answer

0 votes

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

by (47 points)

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!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.