Worst-case scenario: the UEd Goblin wipes the map and burns down your house.

Talk:Everything you ever wanted to know about replication (but were afraid to ask)

From Unreal Wiki, The Unreal Engine Documentation Site
Revision as of 15:06, 12 October 2011 by Omar007 (Talk | contribs)

Jump to: navigation, search

Ah sorry for changing that i thought dynamic would make more sense and have still the same meaning so i dealt with it just like typos and adding categories to someone else his article. --Eliot 19:28, 13 August 2010 (UTC)

So if I get this right....

Ok if I understand this correctly:

1. The

replication{}

block is used to update variables on the client(s). When this happens, depends on the variable used in the if-statement (ie bNetInitial) surrounding the variable.


2. To execute something after a variable is updated, mark the variable for replication notifications using 'repnotify':

var repnotify int myRepInt

This calls the

simulated event ReplicatedEvent(name VarName)

function.

simulated event ReplicatedEvent(name VarName)
{
    if(VarName == 'myRepInt')
    {
        myActionOnRepIntChange();
    }
    else
    {
        super.ReplicatedEvent(VarName);
    }
}


3. If we execute a function on the client (function has to be marked simulated for this) and it needs to be done on the server aswell (to update/notify change to all others), we need a reliable (or unreliable if it's not that big of a deal if it doesn't happen) server function (containing the same logic as the client function).

exec setMyRepInt()
{
    initMyRepInt();
}
 
simulated function initMyRepInt()
{
    myRepInt = 10;
 
    if(Role < Role_Authority)
    {
        serverInitMyRepInt();
    }
}
 
reliable server function serverInitMyRepInt()
{
    myRepInt = 10;
}

I hope this is correct and that if it is the code may enhance the tutorial/QA/overview of replication for others. —Preceding unsigned comment added by Omar007 (talkcontribs) 19:49, 12 October 2011




Yes, that's correct, but it's highly UE3-specific. In earlier engine generations replication of functions is specified in the replication block as well and repnotify/ReplicatedEvent() do not exist. —Wormbo 19:41, 12 October 2011 (UTC)




Yes that is true. I wrote this with the UDK replication syntax in mind as that is what I needed to know for sure ;)

Greatly appreciate you writing this document and confirming my verification question.

--Omar007 21:06, 12 October 2011 (UTC)