Call of Duty style iron sights in UT3

In this post I'm going to explain how to recreate the Call of Duty style iron sights in Unreal Tournament 3. I'm proving a class (which I've heavily commented) to extend to save cluttering up your own weapon code aswell as an example weapon, you'll also need some extra animations which I'll run through.
If you'd like to see this in action then click here to watch a short YouTube demonstration video.
This post was updated on the 19th of April.
The downloadable file is a new version and the part regarding the optional adding of ZoomedTargetFOV has changed. If you altered the ZoomedTargetFOV value in your weapon class (ie if you have that variable in your default properties) you need to remove it if you use the new version of my class. You should now use ZoomedFOVSub and enter a positive value to set how much FOV should be subtracted from the player's FOV, the default is 10. This change makes the zoom system relative rather than absolute and helps with situations where players might have different FOVs set. There are also some other tidiness changes in the functions of my class but they won't be noticeable to a player.
What this code does is setup a weapon to have the alternate fire (right click) be an aim function. Basically when you right click it plays an animation of the weapon moving to the aiming position (like the UT3 Sniper Rifle), tells the game to use a new set of animations for firing and idling so the weapon stays in the aiming position and then plays an animation of the weapon returning to the default position when you right click again.
There are a few other things that are changed while in this aiming mode. AimingWeaponClass changes the movement speed of the player, turns the crosshair off so it doesn't interfere with the sights, makes the weapon more accurate while aiming and slightly zooms in. The example weapon (UTWeap_AimableWeapon) also gives a boost to the rate of fire of the weapon while aiming.
First of all you're going to want to grab this:
Extendable class and example weapon (8.03kb .zip file)
This zip contains AimableWeaponClass which is a subclass of UTWeapon that you can then extend to create your own weapon, there's also an example weapon to show you how to make a weapon which uses the AimableWeaponClass.
To use AimableWeaponClass you'll need to copy AimableWeaponClass.uc into your Classes folder under Src which has your weapon code in it and change the start of your weapon's code to read
class UTWeap_AimableWeapon extends AimingWeaponClass;With UTWeap_AimableWeapon being your weapon class' name.
There are a few numeric variables that you will almost definitely want to add to your weapon's defaultproperties section and configure to suit your weapon, these are:
ZoomGroundSpeed - The player's ground movement speed while in aiming mode (ie their walking/running speed), the UT3 default is 440.
ZoomAirSpeed - The player's air movement speed while in aiming mode (ie the speed they travel through the air when jumping), the UT3 default is 440.
ZoomWaterSpeed - The player's water movement speed while in aiming mode (ie the speed they swim), the UT3 default is 220.
ZoomJumpZ - The player's jump height (ie how many units they travel upward when jumping), the UT3 default is 322.
SpreadScoped - The weapon shot spread while in aiming mode, should be a small value for greater accuracy.
SpreadNoScoped - The weapon shot spread while not in aiming mode, should be a larger value than SpreadScoped for less accuracy.
You can optionally add ZoomedFOVSub. This sets the amount of field of view to be subtracted when the weapon zooms to in aiming mode, larger values for this variable are larger amounts of zoom and the default is 10.
As well as the coding you're going to need four new animations in both your weapon and first person view arm animation sets which are:
WeaponZoomIn - The weapon moving into the aiming position from the normal position.
WeaponZoomOut - The weapon moving into the normal position from the aiming position.
WeaponZoomFire - The weapon firing while in the aiming position.
WeaponZoomIdle - The weapon idling while in the aiming position.
The two positions I refer to are the position of the weapon as it is normally in the bottom right corner of the screen and the position of the weapon while aiming along the sights. In the aiming position the sights of your weapon should target 0 on both the Z axis and the Y axis so they can be used to aim. If you put a camera in 3ds Max facing along the X axis, position it on on 0,0,0 and set its FOV to 60 the two positions will look like this in the viewports.

Ingame the two positions look like this.

