This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

So I am making a sort of Pong game as my first project in this engine, but I hit a dead end. The game has 4 paddles on each side of square (arena), so I need to keep the paddles inside the arena, while the ball can exit any side of the arena. I tried having a collision shape with and exit function, combined with static object collisions shapes at the corners to keep the paddles in, but then they become obstacles, and the ball can't exit trough there. Is there any code or way, in which I can set the space in which the paddles can move without using collision shapes, or anything like that? Thank you.

in Engine by (21 points)

Have you also tried tinkering with the collision layers and collision masks?

1 Answer

0 votes

You don't need to avoid collision shapes, you only need to make sure the ball and the new collision shape(s) don't share the same mask and layer. Newly created shapes default to mask/layer 1. You'll want to set the paddles, the "walls" and the ball to individual layers, and then make it so the paddle mask interacts with both the wall and the ball layer (and the masks of each of these should interact with the paddle layer), but the ball mask should not interact with the wall layer and vice versa. If the paddle has layer 1, walls 2 and ball 3, the paddle mask should be 2 and 3. The ball mask should be 1 only.
The buildup of these walls, provided I'm understanding you correctly, should probably be a StaticBody2D with a CollisionShape2D child.

by (29 points)
edited by
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 Frequently asked questions and 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 [email protected] with your username.