Detect Collision between CharacterBody2D and StaticBody2D

Godot Version

4.2.2

Question

Hello

I’m working on a Breakout game (to learn Godot) and have encountered an issue with collision.

My paddle is structured like this:

CharacterBody2d
– CollisionShape2D
– Sprite2D
– Ball

and in my level, I have a couple of walls on either side of the screen to stop the ball from leaving the area.

The ball collides with the wall, blocks, and paddle and deflects as expected.
However, the paddle can go through the walls:

StaticBody2D
– Sprite2D
– CollisionShape2D

I have checked the ordering, visibility collision layers, and mask for everything many times and can’t figure out why the paddle doesn’t stop when hits the walls

Do I need a code for that? I assumed having the collision nodes would automatically make it so it can’t go through other objects.

Static bodys wont move out of a wall if colliding hence static = wont move. Use a character body node. That has built in logic to move and slide against colliders. Hope th his helps

Is the Ball a child of the paddle? That could be problematic. Are your walls very thin?

Can you show your script for the paddle movement?