UDN
Search public documentation:

ReplicationWeapons
日本語訳
中国翻译
한국어

Interested in the Unreal Engine?
Visit the Unreal Technology site.

Looking for jobs and company info?
Check out the Epic games site.

Questions about support via UDN?
Contact the UDN Staff

UE3 Home > Networking & Replication > Replication in weapons

Replication in weapons


Weapon firing overview


The logic for firing weapons in Unreal Engine 3 is as follows:

Client(s)

  1. The local client controller calls StartFire() within Weapon.
  2. Ask the server's version of Weapon to call ServerStartFire() and also call BeginFire() on the client's version.
  3. Set the byte in the pending fire array within the client's version of InventoryManager.
  4. If the client's version of the weapon is in the 'Active' state, it will then send the client's version of the weapon to the appropriate firing state.

Server

  1. The server was asked by the client to call ServerStartFire() or StartFire() was called by an authoritive Actor. It will then call BeginFire() on the server's version.
  2. Set the byte in the pending fire array within the server's version of InventoryManager.
  3. If the server's version of the weapon is in the 'Active' state, it will then send the server's version of the weapon to the appropriate firing state.

WeaponReplicationTree_Thumbnail.jpg

Weapon stop firing overview


The logic for stopping weapons from firing in Unreal Engine 3 is as follows:

Client(s)

  1. The local client controller calls StopFire() within Weapon.
  2. Ask the server's version of Weapon to call ServerStopFire() and also call EndFire() on the client's version.
  3. Clear the byte in the pending fire array within the client's version of InventoryManager.
  4. Stop firing the weapon on the client.

Server

  1. The server was asked by the client to call ServerStopFire() or StopFire() was called by an authoritive Actor. It will then call EndFire() on the server's version.
  2. Clear the byte in the pending fire array within the server's version of InventoryManager.
  3. Stop firing the weapon on the server.

Weapon properties


  • bOnlyRelevantToOwner - Set true because weapon replication is only relevant for the owning player. Other players don't often need to know the status of other player's weapons.
  • bReplicateInstigator - Set true as the Instigator variable needs to be consistent for the simulation to be accurate.
  • bOnlyDirtyReplication - Set false as the weapon needs to update everything, changed or not.
  • RemoteRole - Set to ROLE_SimulatedProxy as clients need to be able to simulate this actor.

Conclusion


A player's weapon exists as two different versions within a multiplayer game. One version exists on the server and the other version exists on the client. Replication maintains the two versions so that the client can properly simulate what is happening on the server. It is important to note that while this works for weapons, this replication pattern won't work in every case. However, there are many other instances where this replication pattern will work such as skills which require mana.