Adjusting the player’s weapon aim (Part 2)

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.

1) Aiming straight ahead on a flat surface with no obstructions.

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.

——————————————————————————————

2) Obstruction ahead

In this example the player has an obstruction in front of them. This could be a wall or an enemy. Either way there is no point to looking to see if there is a incline or drop head.

A) The pawn should shoot directly ahead without changing pitch.

——————————————————————————————

3) The pawn is facing a slight incline.

Now the pawn is facing a slight incline, if the pawn continues to shoot directly ahead without changing pitch, it will shoot the ground. The second trace will register a shorter distance to the ground. Lets say the distance from the weapon to the ground is 100 units. If the distance from the point ahead (2) to the ground is 50 units, we can use trig to work out that the angle change is 22.5° and then adjust the pitch of the pawn’s aim to 22.5° (Or 4096 in UDK land. Remember UDK measures Yaw, Pitch and Roll in a 16bit integer. 65536 is 360º so 22.5º = 65536/16=4096).

A) The pawn should change the aim pitch.

——————————————————————————————

4) Too steep an incline

If the incline is greater than 45º then the player can’t walk up the slope so there is no point in firing upwards. The first trace will be hit before the second on is called.

A) The pawn should shoot directly ahead without changing pitch.

——————————————————————————————

5) A slight decline.

This option is pretty much the same as the third diagram, aside from shooting downhill rather than up. Note in the example I’ve stated greater than a -45º angle. I’ll come back to this in a minute.

A) The pawn should change the aim pitch.

——————————————————————————————

6) Too steep a drop?

This option leaves me with a question. Unlike an incline that is too steep to climb, it is very possible to fall own a steep decline, so, should the player be able to shoot downwards? This could affect a whole gameplay mechanic and raises other questions. Should the player be able to drop off edges? It seems a bit silly not to be able to fall, but quite often games create an invisible barrier to prevent this. Often a player could get frustrated if the level design kept making it too easy for the player to fall to their death. If I wanted to create a pit of zombies, should I not enable the player to shoot at them first before jumping in? Could this be an opportunity for a different weapon like a grenade to be used to clear the way first? Should the angle be constrained to 45º rather than let it shoot to near vertically negative angles?

A) Suck it and see…

This entry was posted in Uncategorized and tagged . Bookmark the permalink.