Unity netcode what's the difference between ServerRpc and ClientRpc ,Unity netcode issues with clientrpc and serverrpc
Asked Answered
B

1

0

What’s the relation between an ServerRpc and ClientRpc and the difference between a host using one, and a client using one?

I’ve been headbanging for 10 hours (not actually a joke, been sitting 5-6 hours yesterday and 5-6 hours today, at the very least, on the same freaking problem).
So here’s my issue: I’m trying to create this character selection where the player (host and clients) can select a character based on a button (each button represents a character they can select). I’ve tried so many different approaches which doesn’t seem to work .-. And with that I mean, it works perfectly fine for the host, but NEVER for the client.

So the way I’ve got it now, is that when I press a button as a host, it will call a local function which will select a character and disable the UI. As a client I call a ServerRpc with the parameter RequireOwnership = false. However it doesn’t look like the client is actually calling that method, so I made that method call a clientRpc. And that doesn’t seem to work either so I made the ClientRpc call a new ServerRpc. and that made the client at least hide the UI, but still not able to control any characters… I’m just gonna realize that I’ve got no freaking clue what I’m doing and I desperately need help =)

Beneficiary answered 10/12, 2023 at 22:14 Comment(0)
C
0

Server RPC

Code that is run on the Server, called by a Client.

Client RPC

Code that is run on the Client, called by the Server.


Think of server RPC as being the Client instructing the Server to do something, and a Client RPC as the Server instructing a Client to do something.

Chrissy answered 19/1, 2024 at 4:44 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.