Physics2D: how to change angle after collision

Hello world!

I am new to unity and horribly stuck with one bit off code. I am building a simple ‘block breaker’ game that looks a bit like the classic game arkanoid. The game works, but I don’t like the behaviour. When the ball hits a corner of a game object it often flies off (somewhat) horizontally. I want to limit this range so the ball always goes up/down ward with an angle of at least 20 degrees.

I managed to calculate the angle with which the object is hit. Also I have an if statement. Currently I use the AddForce function. I am unhappy with how this works because it alters the speed of my object, rather than only the direction. I have also tried to rotate my object, but that only resulted in my object facing the other way. Is there anybody here who can help me to change the outbound angle? :slight_smile: Thanks!


If you are using Physics for a game like arkanoid its difficult to manage the control the speed of the ball instead try to use colliders for collision detection and move the ball through code by changing the position in update so that you will have control over the speed and behaviour of the ball.