| Home Page | Recent Changes | Preferences

Netcode Idioms

HUD Mutators

See Useful Mutator Functions or Linked List/Existing Lists in Unreal Tournament (use the Quick Navigation menu to browse to "HUD Mutators"). You'll find a description there how to set up a HUD mutator that actually works in network games.

Finding the Local PlayerPawn or PlayerController

The usual idiom for finding the local player's PlayerPawn (UT) on a network client or a listen server is (after declaring a class-level var PlayerPawn PlayerLocal; for UT2003 just replace every occurance of "PlayerPawn" with "PlayerController" and use "DynamicActors" instead of "AllActors"):

if (PlayerLocal == None)
  foreach AllActors(class 'PlayerPawn', PlayerLocal)
    if (Viewport(PlayerLocal.Player) != None)
      break;

if (PlayerLocal != None) { ... }  // do something with it

If you have a Canvas object handy (in engine events like RenderOverlays, for instance), there's even a more straightforward way to get hold of the local player:

PlayerLocal = Canvas.Viewport.Actor;

Note that UT2003 has a function to get the local PlayerController which actually uses the PlayerController/DynamicActors combo (and stores the local controller for later use too):

playerLocal = Level.getLocalPlayerController(); // returns local PlayerController or None if there isn't one

Note that the local PlayerPawn or PlayerController is always relevant (for obvious reasons) and thus always exists on its respective client.

Replicating Config Variables

Clients load the value of config or globalconfig variables from their own .ini files. Since these values are treated as defaults they are not replicated until they are changed through code. Clients will see their own customized configuration instead of the server's.

To force replication of these variables use a second (non-config) variable:

var config string MySettings;
var string ServerSettings;

replication
{
    // replicate the ServerSettings variable to all (relevant) clients
    reliable if ( Role == ROLE_Authority )
        ServerSettings;
}

// non-simulated PreBeginPlay() is only executed on the server
function PreBeginPlay()
{
    ServerSettings = MySettings;
    Super.PreBeginPlay();
}

Related Topics

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

Mapping Topics

Mapping Lessons

UnrealEd Interface

Questions&Answers

Scripting Topics

Scripting Lessons

Making Mods

Class Tree

Questions&Answers

Modeling Topics

Questions&Answers

Log In