Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback for /docs/tutorials/helloworldparttwo.md #144

Closed
JohnMiki47 opened this issue Apr 21, 2021 · 4 comments
Closed

Feedback for /docs/tutorials/helloworldparttwo.md #144

JohnMiki47 opened this issue Apr 21, 2021 · 4 comments
Assignees
Labels
stat:backlog Status - Issue will be addressed in the future.

Comments

@JohnMiki47
Copy link

Hello, I am configuring Hello World project according to this tutorial, but I am little bit confused by the result.
After finishing the tutorial:

  • Start play mode
  • Start as host in one instance, start as client in another instance
  • Connecting as client produces following warning in the console : "Only the owner can invoke a ServerRpc that requires ownership!"

However, as stated by docs:
If we are a client, we call a server RPC. This server RPC simply sets the position NetworkVariable on the server's instance of this player...

So, can a client call a server RPC or only the owner?

@JohnMiki47
Copy link
Author

JohnMiki47 commented Apr 21, 2021

Maybe the solution is as simple as changing this code section:
if (NetworkManager.Singleton.IsServer) { var randomPosition = GetRandomPositionOnPlane(); transform.position = randomPosition; Position.Value = randomPosition; } else { SubmitPositionRequestServerRpc(); }
to this?
if (NetworkManager.Singleton.IsServer) { var randomPosition = GetRandomPositionOnPlane(); transform.position = randomPosition; Position.Value = randomPosition; } else if (IsLocalPlayer) { SubmitPositionRequestServerRpc(); }

Or am I not understanding it correctly?

Thanks for the reply.

@Briancoughlin
Copy link
Collaborator

@Cosmin-B do we need to add some clarification to the guide here or is their an issue with the code as written?

@Alphamplyer
Copy link

I had the same warning ("Only the owner can invoke a ServerRpc that requires ownership!").
The solution is simple. This warning is called when I started the client side. Just add this line to the HelloWorldPlayer.cs script in the NetworkStart Method :

public override void NetworkStart()
{
	if (!IsOwner) return;
	Move();
}

When we start the client the NetworkStart Method is called on both instance of the player script (the host one and the client one).

@Briancoughlin
Copy link
Collaborator

THis is now in process and will be updated. Thanks for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:backlog Status - Issue will be addressed in the future.
Projects
None yet
Development

No branches or pull requests

4 participants