+1 vote

Hello all, I have been testing godot a bit for the last 2 days. So far I'm liking it.

I have been trying to create a small pong-like game where I have a circle made of off many rectangles.

Every rectangle has a rectangle collision shape, and they are rotated to create a circle.
The ball is created with a circleshape.

The problem Im having is that the ball only "bounces" correctly when colliding with either the top or the bottom rectangle, when it hits any other it kind of "throws" the ball out of the circle

Kind of hard to explain so here's a gif showing what I mean:

enter image description here

Here's the code for the ball:

extends KinematicBody2D

const speed = 50
var direction = Vector2(0, -1)
var paddles = []

func _ready():

func _fixed_process(delta):
    var velocity = direction * speed
    var motion = velocity * delta
    motion = move(motion)

    if (is_colliding()):
        var colliding_paddle = get_collider()
        var paddle_color = colliding_paddle.get_color()

        var normal = get_collision_normal()
        motion = normal.slide(motion)

        #new direction, for now take the normal
        direction = normal


Really lost here, not sure how to approach fixing this ... would appreciate any help to make it work :)

in Engine by (13 points)

Set collisionshape to visible in editor perhaps you see something not be correct.
In your gif, it looks like your ball curves. Correct?

the ball is not curving, it's following a straight line. It just looks like its curving because of the circle rotation.

Also, the collision shape seems to always be where it is supposed to (I did try enabling them and couldn't find anything strange about it).

I do think it has more to do with the normal.slide(motion) line...I'm just not very sure how to fix it , if I don't apply the slide, the ball will stop moving after the first collision it detects

Please log in or register to answer this question.

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.