Random force of angle with angle I don't want

Hi guys
I want a ball to change direction to bounce in a different way in a rectangle every time the level restarts.
So I added an action and I applied to the ball a force of angle and in the section Angle I wrote “RandomInRange(1, 359)”. And it worked!
But I I don’t want the ball to have specific angle like: 0°, 90°, 180°…
Otherwise, it will keep bouncing infinitely at a single angle!
So how can I exclude specific angles?
Thank you in advance!

My first idea was that.

The ball doesn’t move.
(The variable “ValidAngle” is a variable number set to 0)

this is the other image (I couldn’t put them together)

You can display the random number in a text object before applying them to the ball, to test. The problem could be that a number comes up that is excluded in an upper subevent. I didn’t know you wanted excluded so many.
I think there is a solution for this using arrays but I don’t know it, I’m sure someone else can help.

What about something like this? You can change the range.

NextAngle = RandomInRange(5,85) + 90 * Random(3)

Or if you also want to limit perfect diagonals

RandomInRange(5,40) + 45 * Random(7)

I drew black lines using both methods. It basically picks a a range in 1 segment and then picks a random segment. Sort of like a side.

Thank you man, I think it worked! (What does “+45 * Random(7)” means?)
I did this:

But I’ve other two problems.

A circle is 360°
If you break into 45° sections there are 8
It picks a random angle in the first 0° to 45°
(Or °5 to °40)
There are now, 7 sections left.
adding 45*Random(7) picks one of those sections. Or the first section if the random number is 0

As for the speed increase. I don’t know.

The Spherez example might help.
The game scene.

https://gdevelop.io/game-example/free/spherez

You might need to use Random(10,35)

Also, make sure the balls hit box (shape) is set to circle within the physics behavior.

I didn’t notice anything in Spherez that checks for a ball that gets stuck in a loop. Maybe I missed something.

If it’s still an issue maybe the movement angle needs to be checked and adjusted. IDK. There should probably be some backup.

Compare the physics setup between yours and Spherez for the ball and the obstacles or walls. Maybe something there helps to prevent being stuck in a loop. Maybe the physics settings add a bit of randomness when there’s a collision through friction or dampening.