| Home Page | Recent Changes

How UT Weapons Work/Switching To Another Weapon

Switching weapons consists of two parts

  1. putting down the old weapon
  2. bringing up the new weapon

1  Putting Down The Old Weapon

Weapon changes can origin from different functions, like PlayerPawn.SwitchWeapon, .GetWeapon, .Prev/.NextWeapon or Pawn (UT).SwitchToBestWeapon. All these functions have a common structure:

  1. The pawn's PendingWeapon property is set to the new weapon.
  2. If the pawn's Weapon and PendingWeapon are already the same switching is aborted and nothing happens.
  3. If the pawn doesn't currently have a selected Weapon, PendingWeapon is brought up. Otherwise the current weapon's PutDown function is called. This function can in some cases abort the weapon change by returning False. (e.g. SwitchWeapon function)

2  Bringing Up The New Weapon

This part of the weapon change starts with the Pawn (UT).ChangedWeapon function. This function acts differently depending on whether Weapon and PendingWeapon are the same or not:

When the pawn has no weapon selected and no weapon to switch to (Weapon == PendingWeapon == None) then the SwitchToBestWeapon function is called. Otherwise if Weapon and PendingWeapon are the same and in DownWeapon state, the weapon's BringUp function is called.

When Weapon and PendingWeapon are different and PendingWeapon is None it will be set to Weapon. Then the pawn's PlayWeaponSwitch function is called to play an animation for changing the weapon. When the PendingWeapon's mass is greater than 20 and the pawn caries a decoration, the DropDecoration function is called. Afterwards Weapon is set to PendingWeapon.

Then (in all cases) the selected weapon's SetDefaultDisplayProperties function is called and the pawn's inventory receives a ChangedWeapon call. The ChangedWeapon function of each item should call the ChangedWeapon function of the next item in the pawn's inventory chain. In case Weapon and PendingWeapon were different the weapon's RaiseUp function is called.

ChangedWeapon always returns with PendingWeapon set to None.

(...)


Category To Do

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In