This question already has an answer here:
I have a collision in my game (see below) and a ball which is moving in a certainly speed to a random angle (x, y).
My problem is. If it touches the collision it should reflect.
I simply multiply the Y-value of my ball by -1 (negative 1), which works fine!
The main problem is my collision looks like this.
I made it like when the ball collides the red collider it should multiply reflect the y-value. If it collides the yellow collider it reflects x-value.
But... what happens when the ball coming from left to up (like on picture) and collides the red value. It just changes the y-value.
Maybe there's a way to make it easier, but I don't know it.