#i am trying to create pong to learn godot but im stuck on making the ball
11 messages · Page 1 of 1 (latest)
You do not need var there because you have already defined the variable on line 6
Second thing: only check each raycast if the ball velocity is in the same direction
Like:
if velocity.x > 0 and $RayCast2D_right.is_colliding():
velocity.x = velocity.x * -1
i applied that but it still doesnt work, the problem is that it reverses the direction but only while the ray cast is still colliding, i need it to work like a switch but it isnt
nvm js got it bouncing
i needed to replace "velocity.x = velocity.x * -1" with "SPEED = velocity.x * -1"
new problem i now get this error when trying to launch the game
Does the paddle script have a line at the top that says “extends CharacterBody2D”?
Both paddles will need it
i figured it out i just needed to make the root node a character body 2d instead of a Node2D