- Home /
Ping Pong bat is not detecting the collision with the wall
Hi everybody ,
I am a n00b . I am learning Unity from last couple of days . I want to make one simple ping pong game . Idea is simple . The game has a Sphere as a ball , a plane as ground , 2 rectangle as bats and 4 rectangles as wall . Look at the image .
It is 2 player game . One player will use 'W' and 'S' key and another player will use 'Up Arrow' and 'Down Arrow' on the keyboard to move the bat up and down .
But I have a problem here . If a player moves the bat very up or very down , the bat does not detect the collision with the wall . It just goes through the wall . Look at the image . .
The bat and the wall has Box Collider , but still it gives the problem . So what to do so that the bat detects the collision with the wall .
So please let me know where I went wrong . I am a beginner , your help will definitely help me in future .
Thanks :)
Answer by erebel55 · Jun 04, 2015 at 01:06 PM
You will need to either put a rigidbody on the paddle's so that it is controlled by physics http://docs.unity3d.com/ScriptReference/Rigidbody.html
Or code a collision response (the detection is probably already working)
Research OnCollisionEnter or OnTriggerEnter to response to the collision detection. On the response you will want to stop the paddle from moving in that direction.
http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionEnter.html http://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html
You could also just limit the movement of the paddles in the appropriate axis, so that you don't even have to deal with collisions with the wall.
Your answer
![](https://koobas.hobune.stream/wayback/20220613200421im_/https://answers.unity.com/themes/thub/images/avi.jpg)