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 :slight_smile:

You will need to either put a rigidbody on the paddle’s so that it is controlled by physics Unity - Scripting API: Rigidbody

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.

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.