I had an idea. Why not pose programming problems and then see what discussion ensues, perhaps with a reveal of my solution. Yes, you can tell I am still a teacher (perhaps much to the chagrin of some). So I will give it a go.
I remember when I told someone in their early twenties “I have been making games since I was 12″. To which the challenged me with “So did I” as if they were my equal. Do the math. I am 20 years older than you matey.
Maths is important. And that is going to be the subject of the problem I am presenting here.
One of the game prototypes I am working on (I am usually working on a personal prototype of some kind in unity these days) requires that I test to see if the player passes through a gate, rather than around it. Something like the gates of skiing. So, how can this be elegantly done?
You have the position of the player, the position of the sides of the gate. You must have a piece of code that is called at the right time to detect if the gate is properly taken or not. When this is detected, the game will switch to the next gate. The solution needs to work in 3D, but you can assume that the gates themselves are vertical.
What is the best solution you can come up with , in terms of size of code, clarity and robustness?
In a later post I’ll discuss my solution and we can compare notes.