PDA

View Full Version : Replicate from a mutator?


Traktion
18th Nov 2004, 12:40 PM
Hi,

I'm attempting to replicate some variables from the client to the server. I started by adding the replication block and set it to:

replication
{
// Things the client should send to the server.
reliable if( Role<ROLE_Authority )
bPlayerArrayChanged;
}

This seems to be correct, but whenever I change this variable in a simulated, client side function (which is called from my simulated function tick in my mutator when role == ROLE_SimulatedProxy), the server side version (called from the same tick routine, but when role == ROLE_Authority), the value never changes.

Am I doing something wrong or can you simply not replicate variables from a mutator?

Thanks in advance!

draconx
18th Nov 2004, 11:07 PM
I believe you can only replicate from client to server if the client is the owner of the actor doing the replication.

And for simulated functions in a mutator to run on the client at all, you'll have to make sure your package is in the ServerPackages list in unrealtournament.ini

Traktion
19th Nov 2004, 05:11 AM
Regarding the owner of the pawn, well, I was hoping to just replicate the variables in the mutator itself. I have programmed my mutator to run some stuff client side and some stuff server side, but wanted some way of updating the server side variables from the client side. From looking here http://wiki.beyondunreal.com/wiki/Netcode_Idioms , it looks like there are alternative ways of doing it. I'll also look into altering the mutator to make the client the owner to allow the replication from client to server. I'll post up my results.

Regarding the server packages, that is all setup and running. The mutator works fine, but the replication isn't working as required yet. I'll keep you all posted.

Loqa
19th Nov 2004, 03:36 PM
I'm a total noob at replication, well somewhat of a noob, so take my comment lightly.
I thought that mutators only excisted serverside? Thus making it very difficult for the client to be the owner of the mutator, as I think you're sugesting.

Traktion
20th Nov 2004, 08:35 AM
They definitely exist on both server and client side as you can run simulated functions and such from the client. For instance, my mutator makes a TcpLink connection from the client IP address and gets some data from another server app. I think I've made progress if you read my other thread about the SpectatorOnly=1 problem. Thanks for input though!

Kamek
21st Nov 2004, 02:08 AM
You can't replicate variables from the client to server unless the client owns the actor. Since the client does not own the mutator, it won't work.

However, you can have the mutator spawn helper actors as each client logs in, setting the helper actors as owned by the PlayerController of the client, then have the client send info to the helper actor, which in turn can call a function on the mutator or change the mutator's properties on the server side.

Hope this helps.

Mychaeel
21st Nov 2004, 11:44 AM
You can't replicate variables from the client to server unless the client owns the actor. Since the client does not own the mutator, it won't work.
I've not managed to get any variables replicated from client to server at all -- I think the only place where that works are certain classes with some native magic behind them such as PlayerController.

However, replicating function calls from client to server works well for all replicated classes if (as said above) the actor is owned by the client doing the client-side function call. Kamek's suggestion will work nicely with replicated function calls as well.

Traktion
22nd Nov 2004, 04:43 AM
Interesting stuff... I was just about to start writing an extra Actor to sit on top of the Mutator to see if that would work with replication. Has anyone tried this before?

I've actually found a different way around my problem by calling server side functions from my simulated client side functions. It's not very clear what is going on (as the logging seems to stop working when you call a function remotely), but the results reflect that it works.

BSands
15th Dec 2004, 08:16 AM
you can have the mutator spawn helper actors as each client logs in, setting the helper actors as owned by the PlayerController of the client

Just curious what people have found to be the cleanest way of doing this? Particularly, I wonder what is the most efficient method for having the mutator spawn a custom ReplicationInfo for each entering player.

Wormbo
15th Dec 2004, 11:18 AM
Client->Server replication for variables only works in UT, not in UT200x. You should use replicated function calls there.