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

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
m
Line 69: Line 69:
  
  
 +
==Name type==
 
Is it just me doing something wrong or is the replicating of Name variable types not possible? When I send a Name variable from server to client the client may receive 'bTrackMouse' when the server actually sent 'foo', it seems that the engine just sends the name index instead of sending the new name string for the client to register to its internal Names list, either that or I am doing it wrong?
 
Is it just me doing something wrong or is the replicating of Name variable types not possible? When I send a Name variable from server to client the client may receive 'bTrackMouse' when the server actually sent 'foo', it seems that the engine just sends the name index instead of sending the new name string for the client to register to its internal Names list, either that or I am doing it wrong?
 
--[[User:Eliot|Eliot]] 12:31, 10 March 2014 (UTC)
 
--[[User:Eliot|Eliot]] 12:31, 10 March 2014 (UTC)

Revision as of 06:31, 10 March 2014

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)


Name type

Is it just me doing something wrong or is the replicating of Name variable types not possible? When I send a Name variable from server to client the client may receive 'bTrackMouse' when the server actually sent 'foo', it seems that the engine just sends the name index instead of sending the new name string for the client to register to its internal Names list, either that or I am doing it wrong? --Eliot 12:31, 10 March 2014 (UTC)