Proper use of Switch Has Authority

Hello, sorry if this is a really silly question to ask, but I’ve been messing around with the networking part of blueprints and I’ve somewhat come across a hurdle.

I’ve been trying to make one of the two characters(either server or client) to attach a weapon they find on the ground. The problem was that every time only the server actually saw either the client or himself equipping the weapon, while the client didn’t see anything. After some experimentation I’ve found that if I want the client to equip the weapon, he has to send a request to the server. Eventually I ended up having to use two different replicated functions, one for sending a request to the server and one for multicasting the change to every other player.

Here’s the first of my two questions, is this a proper way to do things or am I sending unnecessary load to the server?

The second question is, on which function do I need to use Switch Has Authority ? As you can see in the image, I’m currently using on the first one because it only works there.If I try to use a Switch Has Authority on the second function, it acts as if I’m not sending data to the server. Is this how it’s supposed to be, or am I not sending data properly?

Switch has authority just tests if the player is the client or the server.

So everything behind “Authority” only gets called if it’s called on the server and everything behind “Remote” gets called if a client uses it. I guess the server itself counts as a client too :X.

If you have a replicated variable, that holds your weapon, you can make a custom event that is called by client and only runs on server (so behind the red node you put the Switch node and take the Authority). If the client knows what he picked up, you could pass the weapon by the custom event inputs and fill the variable with it. If the variable is replicated, you don’t need the multicast i think. This is what you already did i guess?

I don’t know if your variable is set to replicate, so you could try changing this and removing the multicast. If it doesn’t work, then i’m wrong, sorry. (: But at least give it a try. If you current setup works completely fine, i guess you can stick to it.

The best thing to learn the networking system is to watch the networking videos on Youtube, made by Epic. They teach you how to replicate things to other players and much more.

Most of the time i have a twist i my head too, thinking about the networking RPCs.

5 Likes

apparently it doesn’t exactly check for server/client but for owning/not-owning