The main mechanic of this game is that rockets will bounce off of walls. The player will have to judge their bank shots correctly in order to hit a certain target (or avoid hitting other targets). This will all be made possible by this Physics-related type thing called the Law of Reflection.
This law states that a ray cast towards a surface will reflect off of it at the same angle it hit: like in the diagram above, the angle of incidence will be equal to the angle of reflection.
Though the law of reflection initially applies to light rays and specular reflection, it can also be applied to the trajectory of moving objects. If you think of a game such as "Breakout," this law holds true: the ball bounces off of a wall at the same angle it hit it. Now this effect is easily reproducible for round objects (such as a ball or sphere), but I'm trying to bounce cylindrical rockets (which actually have a simplified rectangular collision mesh). The collision system won't naturally allow a box to reflect in this manner, so I get to force it manually. Fun.
So, does this equation look familiar to you?
Unless you watched the video I did on the kart racer's artificial intelligence system and paused the video at this exact point with the express purpose of knowing and learning this equation, probably not.
But here's where the kart racer's AI system comes in. Part of the script includes an equation that outputs an angle measure when given two vectors. The two vectors I worked with were the kart's world orientation vector (what direction it was pointing in), and the steering vector (which pointed in the direction the kart needed to go).
The exact same mechanic applies here. I still have to calculate the angle between two vectors: only this time, between the direction the rocket is facing with the direction the wall is facing. I can get these by grabbing the rocket's world orientation vector and the wall's surface normal.
The only trouble I foresee is actually rotating the rocket. With the kart's AI, the script ran continuously because it always needed to steer the kart. But to control the rocket, I have to save the calculated angle and rotate the rocket by that amount the instant it collides with the wall, then recalculate the angle for the next collision. I'm not immediately sure how to pull this off, but I'll see when I get there.






