Kaz
Kaz

Reputation: 147

Unity breakout game change direction of ball based on which part of the paddle it made with collision using c#

I am experimenting with a 2D breakout game (in c#) using Unity 5 and wanted to know how I can change the direction of the ball based on which part of the paddle it made collision with.

For example if the ball touched the left part of the paddle then the ball should go left and if it struck the middle then it should go straight up and if it struck the right side then go right.

Upvotes: 0

Views: 370

Answers (1)

user6738423
user6738423

Reputation: 26

You can make 4 different box colliders 2d on the every side of a paddle as a child object and add OnCollisionEnter2d() method to them where you can apply your mechanics

Upvotes: 1

Related Questions