Now that Roll, Pitch and Yaw are clearer, it’s almost time to focus on pitch and how we are going to use this to aim the players weapon up or down hill.
There are a few rules that have to be considered first, so to aid with visualising the issues, I’ve drawn a few diagrams. When I have a problem to overcome, I try to visualise real world logic and in this case I intend to use two traces to look for a collision with the ground and any other objects.
In this first diagram. The first trace goes from the player (1) to a position in front of the pawn (2) which is equal to the weapon’s height from the ground. Then from that point (2) another trace is run to gauge the distance from the ground (3). In this example the ground is flat, the first trace has no obstruction and the second trace will register the height ahead as no different from the weapon’s distance from the ground.
A) The pawn should shoot directly ahead without changing pitch.