Replication of Variables in UScript – Take 1

There is a problem with my replicated mutators. They rely on the Tick function to force things to be replicated properly. The issue being that the tick function is called in between every frame being rendered to the screen and as such may impact game responsiveness or create lag under some conditions. I chose this method because of one simple reason – it worked. Replication is one of those issues where if you don’t get it working just right things don’t work. The straw that broke the camels back is often something that is misunderstood or possibly just something a developer is ignorant to. Getting replication working in the first place is often the accomplishment of many of us.

That said, it has become a goal of mine to better understand replication and I will not be working on anything else until I get my mind around how to network this shit.

Last night I began, about 8:00pm, working on this replication issue. The tick function was retired and I began working on the repnotify and ReplicatedEvent as is discussed to a degree in the forum thread here. A general solution has yet to be developed and as such we are at a loss.


Actors should be notified (via the ReplicatedEvent function) when this value for this property is received via replication.

This is the entirety of the entry, available on the script reference. As a developer this really doesn’t mean a whole lot, but when you look a step further

// Called when a variable with the property flag "RepNotify" is replicated
simulated event ReplicatedEvent(name VarName);

This is the declaration of the function. It still isn’t saying much but with a little testing I was able to establish its usage. It is an event on the Client during a network (or LAN) game that is executed when each variable is sent to the client, letting you know which variable is set, by its name. With a little CodeFu I was able to write this function for my JumpMod Info Class which does two things, keeps track of which variables are set (actually this counts the number of times the variables I have are set). I know this because I’ve seen more than four in my ready variable so this method is probably not the best. A variable for each, an array or a little bit twiddling would probably be better but this worked for testing so ill just use it.

simulated event ReplicatedEvent(name VarName)
    switch (VarName)
        case 'MyPawn':
        case 'riMaxNumJumps':
        case 'riMaxJumpBoost':

What needs to be understood here is one beautiful thing. I am no longer using the tick function for any of this.


  1. Replicate the variables
  2. When the variables have all been set…
  3. Set our jump count on the pawn.

There is however one issue that is still being a pain in the ass. I need to set the variables on the server and the client. The ReplicatedEvent function itself is only executed on the clients, but more than that its executed before I have access to the pawn itself and as such I cannot set a pawn that I don’t have. =(

This is where I am currently. More when I figure it out further. My code is available, as always, on my svn.

I have to say thank you to Blade for giving me some important insight into this replication issue.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.