The three virtues of a programmer: Laziness, Impatience, and Hubris. – Larry Wall

Difference between revisions of "Talk:Everything you ever wanted to know about replication (but were afraid to ask)"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
(So if I get this right....: new section)
Line 50: Line 50:
  
 
I hope this is correct and that if it is the code may enhance the tutorial/QA/overview of replication for others.
 
I hope this is correct and that if it is the code may enhance the tutorial/QA/overview of replication for others.
 +
{{unsigned|Omar007|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. —[[User:Wormbo|Wormbo]] 19:41, 12 October 2011 (UTC)

Revision as of 13:41, 12 October 2011

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)