2D Ray Reflection (Like Bricks Breaker Quest)

Hello everyone. Can someone suggest a code for ray reflection on walls (aiming) ?

There is a method for just that:

1 Like


I’ve actually tried that method before but the reflection is very fickle, meaning that at certain angles, it reflects but at other certain angles it doesn’t even appear, could it be because of the code?

And one more thing, for me, " Vector2.Reflect" works perfectly for reflecting objects but in the ray reflection case, I haven’t been able to find a good solution for it.


I found out what the problem was. You have to do what I did in the picture, meaning if you want it not to be fickle, you must add the reflection direction to it (you must reduce the direction which is 1, if not, the reflection position will be off, just follow the example of my multiplication).

1 Like