I did create game objects
-Top wall: square sprite, Box collider 2D
-Down wall: square sprite, Box collider 2D
-ball: cricle sprite, Rigidbody 2D, circle collider 2D with physcis material for bounce
-left paddle: Rigidbody 2D, Box collider 2D
-right paddle: Rigidbody 2D, Box collider 2D
The problem I face is that the left and right paddles are passing through the walls. I need the paddle to stop at the walls.
I asked ChatGPT, and it says that “add a box collider and limit the Y axis that matches the wall’s Y axis (wall=4.5 limit has to 4.4)”
But still, my problem isn’t solved
How to solve my problem?
It is likely in how you are moving the paddles, which you have given zero detail about, or perhaps you have another bug. Either way… time to start debugging!
By debugging you can find out exactly what your program is doing so you can fix it.
Use the above techniques to get the information you need in order to reason about what the problem is.
You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.
Once you understand what the problem is, you may begin to reason about a solution to the problem.
Remember with Unity the code is only a tiny fraction of the problem space. Everything asset- and scene- wise must also be set up correctly to match the associated code and its assumptions.
As you learn more, if something still does not make sense, try this format:
How to report your problem productively in the Unity3D forums:
This is the bare minimum of information to report:
- what you want
- what you tried
- what you expected to happen
- what actually happened, log output, variable values, and especially any errors you see
- links to actual Unity3D documentation you used to cross-check your work (CRITICAL!!!)
The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven’t put effort into finding the documentation, why should we bother putting effort into replying?
If you post code, only post the relevant code and always use the format button above. Do not post photographs of code.