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!

Report article 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 DazJW on Mar 24th, 2009 digg this super bookmark
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 YouTube demonstration video.

<!--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 Apr 23 2009, 2:30pm says:

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

+1 vote     reply to comment
Post a Comment

Only registered members can share their thoughts. So come on! Join the community today (totally free) and do things you never thought possible.

Track this game Profile
Icon
Unreal Tournament 3
Platforms
PC, X360, PS3
Developer & Publisher
Epic Games
Contact
Send Message
Official Page
Unrealtournament3.com
Release Date
Released Nov 19, 2007
Game Watch
Track this game
Bookmark
Digg Super bookmark
Tutorial
Browse
Tutorials
Report Abuse
Report article
Bookmark
Digg Super bookmark
Related Games
Unreal Tournament 3
Unreal Tournament 3
Single & Multiplayer First Person Shooter
Related Engines
Unreal Engine 3
Unreal Engine 3
Commercial Released Sep 1, 2007
Related Groups
Epic Games
Epic Games
Developer & Publisher
Unreal Tournament 3 Developers
Unreal Tournament 3 Developers
Fanboys & Clans group with 193 members