Unreal Tournament 3 marks the return of the world's première first-person shooter. It unleashes the full power of Unreal Engine 3, taking graphics, gameplay, and challenge to a whole new level. Players engage in intense battles with other human players online, or against Unreal artificial intelligence that sets the industry standard. With the most powerful futuristic weapons and vehicles available, this is FPS action at its best!

Post tutorial Report RSS Call of Duty style iron sights in UT3 Tutorial

This post was updated on the 19th of April, please download the new file and note the changes. In this tutorial I explain how to recreate the Call of Duty style iron sights in Unreal Tournament 3. I've providing 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.

Posted by on - Intermediate Client Side Coding

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.

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.

If you'd like to see this in action then click here to watch a short demonstration video on ModDB.

<!--more-->

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, with downloaded version of this post (571kb .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.

Normal weapon position in 3ds Max

Aiming weapon position in 3ds Max


Ingame the two positions look like this (excuse the lack of arms).

Normal weapon position in UT3

Aiming weapon position in UT3


Everything should then function correctly.


By DazJW.

Comments
MrBCut
MrBCut

Hey DazJW!

Nice to meet you! This seems to be a well put together gameplay feature. Thanks dude! I can think of some variants where this will come in handy.

Adding you to my friends list( if you don't mind. :) )

MrBCut

Reply Good karma Bad karma+2 votes
Cédrico
Cédrico

Hello there, very nice tutorial, would you mind explaining the extra steps between the classes and final compiling, because I created my mod folder in development/src, i added the file, change the default ini file with the new mod name and did a full recompile. No errors reported, i know you can't really see the result because of the extra animation sets needed, but is there a way to know everything went fine ?

THX a lot

Reply Good karma Bad karma+1 vote
DazJW Author
DazJW

You should be able to notice the difference in speed and accuracy while aiming.

Reply Good karma+1 vote
SunOfABeach888
SunOfABeach888

could you maybe describe a bit more what you need to change ? I just cant pull it off .. Its so hell difficult to find something about on the web, and everyone does it different. Your method seems to be the best - but is this still actual ?

I dont really get what AimingWeaponClass does or where or what it should replace, and in which folder from the 2 it comes :/

I think a lot of people would be happy about a really nice video tutorial :) I would do something in return, Im really good at photoshop and pretty decent in modeling.

Reply Good karma Bad karma+1 vote
aries420
aries420

err i got some errors with yer class first which was
AimingWeaponClass.uc(312) : Error, Redefinition of 'event OnAnimEnd' differs from original - 'optional' mismatch on parameter 1

and after removing the optional's i get this
AimingWeaponClass.uc(161) : Error, Can't access protected variable 'FOVAngle' in 'PlayerController'
AimingWeaponClass.uc(133) : Error, Bad or missing expression after '&&': 'IsActiveWeapon'
AimingWeaponClass.uc(126) : Error, Can't access protected variable 'FOVAngle' in 'PlayerController'

im not to shore how to get around these ones, do you have an updated tutorial for this, or is it no longer supported in the 2012 builds?

Reply Good karma Bad karma+1 vote
UDK_CODER
UDK_CODER

i had eror superclass UTWeapon MP7 of classAimingWeaponClass not found
any idea what should i do?

Reply Good karma Bad karma+1 vote
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Follow Report Profile
Icon
Unreal Tournament 3
Platforms
Windows, X360, PS3
Developer
Epic Games
Publisher
Midway Games
Contact
Send Message
Release date
Game watch
Follow
Purchase
Tutorial
Browse
Tutorials
Report
Report
Share
Related Games
Unreal Tournament 3
Unreal Tournament 3 First Person Shooter
Related Engines
Unreal Engine 3
Unreal Engine 3 Commercial
Related Groups
Epic Games
Epic Games Developer & Publisher with 6 members
Midway Games
Midway Games Developer & Publisher
Unreal Tournament 3 Mod Developers
Unreal Tournament 3 Mod Developers Fans & Clans with 229 members