A very common game behavior for the player (or a computer-controlled non-player-character (NPC)) is to fire a projectile in the direction they are facing. This recipe presents a way to achieve this behavior.
Although there are several steps in this recipe, there are just three script classes, and most of the work is in setting up the cube wall and red sphere projectile, as seen in the following screenshot:
0423_09_05 folder, you'll find a stone image texture file called
stones.png shown as follows:
To fire a projectile, perform the following steps: