Skip to content

feat: bootstrap template sample featuring basic RPC usage & movement with NetworkTransform#1120

Closed
fernando-cortez wants to merge 2 commits intodevelopfrom
feature/bootstrap-template-sample
Closed

feat: bootstrap template sample featuring basic RPC usage & movement with NetworkTransform#1120
fernando-cortez wants to merge 2 commits intodevelopfrom
feature/bootstrap-template-sample

Conversation

@fernando-cortez
Copy link
Copy Markdown

This PR introduces the first Sample under the Netcode for GameObjects package.

Preview of how it'll appear inside Package Manager:
1

Preview of how it gets pulled into your project:
2

This sample features:

  • Connection via GUI
  • Basic RPC usage
  • Movement via NetworkTransform with Server authority

@0xFA11
Copy link
Copy Markdown
Contributor

0xFA11 commented Aug 31, 2021

I wasn't aware of such plans, do you have a JIRA ticket that I might get more info/context? 👀

@fernando-cortez
Copy link
Copy Markdown
Author

@MFatihMAR https://jira.unity3d.com/browse/MTT-1008

/// </summary>
public class BootstrapManager : MonoBehaviour
{
void OnGUI()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should apply coding standards to these source files as well.
I wonder why it passed CI checks, maybe because it doesn't create a csproj or sln file?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we had a conversation with Fernando. there are couple of extra steps to make samples compile and also eventually part of CI standards check. I'll create another JIRA ticket for this issue and address those over there.

/// "Server", this transform's position modification can only be performed on the server, where it will then be
/// replicated on all other clients.
/// </remarks>
public void Move()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we just call SubmitPositionRequestServerRpc(); in OnNetworkSpawn and transform.position = GetRandomPositionOnXYPlane(); in SubmitPositionRequestServerRpc() and remove the need for this move function?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're very right here. I was doing ownership checks manually on the BootstrapPlayer, when this isn't necessary.

"com.unity.nuget.mono-cecil": "1.10.1-preview.1"
}
}
} No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git being git :)

0xFA11
0xFA11 previously approved these changes Sep 1, 2021

static void SubmitNewPosition()
{
if (GUILayout.Button("Move Local Player"))
Copy link
Copy Markdown
Contributor

@JesseOlmer JesseOlmer Sep 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have NetworkTransform for movement, it feels weird to use RPCs to "move local player" instead of the dedicated type we provide for doing this... and, specifically, this depends on what ends up landing based on the "client authority netvar" stuff that Sam & Matt have been looking at.

Maybe NetworkTransform to move the player, and then a button for "shooting" or spawning or some other RPC event?

@SamuelBellomo thoughts?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not actually moving the object, it is asking server to teleport us to a random position on the server side. so the actual networktransform movement/replication is still handled by the networktransform component itself.

FWIW, we might make method names better though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 Fatih
@fernando-cortez we could use "RandomMoveServerRpc"? Or "MovePlayerRandomServerRpc"?
I also added a small comment suggestion improvement to clarify that NetworkTransform is the one replicating to other clients

/// <remarks>
/// Since a NetworkTransform component is attached to this player, and the authority on that component is set to
/// "Server", this transform's position modification can only be performed on the server, where it will then be
/// replicated on all other clients.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// replicated on all other clients.
/// replicated on all other clients.
Suggested change
/// replicated on all other clients.
/// replicated on all other clients through NetworkTransform.

@0xFA11 0xFA11 self-requested a review September 3, 2021 09:22
@0xFA11 0xFA11 dismissed their stale review September 3, 2021 09:22

needs re-review

Copy link
Copy Markdown

@UnityGio UnityGio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Fernando. Thanks for adding me for visibility, but I don't think I'm the best person to do code reviews.

@fernando-cortez fernando-cortez deleted the feature/bootstrap-template-sample branch September 7, 2021 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants