Switch Has Authority and different player colors

Hello!

I’m playing around with Paper2D and thought, hey, why not try to make a fun cooperative platformer! So I started investing my time in watching the network tutorials in one go and immediately afterwards I started implementing it into the Paper2D project with some temporarily borrowed graphics from “Kenney.nl Platformer Pack”. What I’m trying to accomplish however, does not give me the expected results.

Basically, I’m trying to set player sprites at the beginning of the game (Begin Play event under “My Character”). I thought it would be as easy as just adding a “Switch Has Authority” and set the different sprites for the server and client.
The client see itself as a pink alien and the server as a blue alien (expected). The server however, see both itself and the client as a blue alien and I guess this is because the sprite change of the client only happens on the client-side (kinda obvious).

I’m unsure on how to go on about this in blueprint. If I think in code I would check how many players are in the server, then go through each one of the connected players class and set a color, then send that color information to all clients and it should work.
If I think like that in blueprint, I would setup a custom event with multicast and run as authority and then get the number of connected players (GetCurrentPlayers?), then go through each of them and set the sprite accordingly (SetFlipBook). However, I’m not sure how to use SetFlipBook and point it towards a specific client - right now “target” is set to the sprite inside the MyCharacter and does not point towards a client->mycharacter->sprite.

Maybe I’m just overthinking everything, maybe there is a hell of a lot easier way to do this in blueprint. I’m all ears, help :P!

Included a screenshot of the failed attempt for the lulz!

Hey, so you want the server also to see himself as the blue alien and the rest als the pink one?

http://puu.sh/efgMt/aa4d41ffbd.jpg

I hope this can be used for your problem. I changed the characters Mesh. But you should be able to
do the same with the Flipbook.

This runs on the server, because the server has all knowledge about all PlayerControllers. The Client only has
its own PlayerController. Then i checked that the server itself doen’t get involved by checking that the Controller
isn’t the same as the original one of the server (GetPlayerController with Index 0).

Now i got the Controlled Pawn and casted it to MyCharacter Class. I created a custom event that is replicated to from
server to owning client. I created an input of type MyCharacter to pass the Character i want to change.

It is important that you don’t plugin something to “Target”. If you would do this, it will only call this on the Client that
belongs to the Target (must be of MyCharacter). But we want it to happen on every client for every client, so we just
say that this should happen on all the clients.

I guess, leaving the Target blank does something like “All Clients belong to the server, so using self on the server
will get all Clients to be changed here”. But i could be wrong. At least it is working like i think it should x)

If you still have problems, feel free to ask me.

Thanks eXi!

I’ve not tried the blueprint setup just yet but at a first glance it looks like a perfect hit. I was not familiar with the “Get All Actors Of Class”, this totally makes sense!

I might as well hijack my thread for another matter that I noticed in multiplayer - physics. I got an object with physics simulated (and replicated; tried with replicated movement as well) and the physics mismatch big time between the server and client. Any idea why that would happen? Maybe I need to create some sort of event of the object involved when it’s working with its physics calculations and pass something on to the clients from there?

Hm, i can’t tell without knowing what you exactly setup. And even with your setup i might not be able to tell you what is
wrong, since i haven’t worked with replicated physics yet.

Do you mean something like this that Rama made with C++?

https://forums.unrealengine.com/showthread.php?17078-Video-Player-Controlled-Replicating-Physics-Movement-Simulating-Physics!&highlight=physics+replication

:confused: Maybe search google for somekind of tutorial.

Normaly all replicated movement should be enough to replicate the transform of an object, but i guess only the server is allowed to
move something, so that could be the problem for your physic approach.

It’s basically one of those tutorial platforms and I’ve just replicated it but it does not replicate it’s transform very well I’m afraid :P. Looked into the thread you posted and it seems interesting, I’ll have to dig really deep into blueprint to figure that one out but I did get some clues, thanks for sharing the thread :).