feat: bootstrap template sample featuring basic RPC usage & movement with NetworkTransform#1120
feat: bootstrap template sample featuring basic RPC usage & movement with NetworkTransform#1120fernando-cortez wants to merge 2 commits intodevelopfrom
Conversation
…with NetworkTransform
|
I wasn't aware of such plans, do you have a JIRA ticket that I might get more info/context? 👀 |
|
@MFatihMAR https://jira.unity3d.com/browse/MTT-1008 |
| /// </summary> | ||
| public class BootstrapManager : MonoBehaviour | ||
| { | ||
| void OnGUI() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
com.unity.netcode.gameobjects/Samples~/Bootstrap/Scripts/BootstrapManager.cs
Outdated
Show resolved
Hide resolved
| /// "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() |
There was a problem hiding this comment.
Why don't we just call SubmitPositionRequestServerRpc(); in OnNetworkSpawn and transform.position = GetRandomPositionOnXYPlane(); in SubmitPositionRequestServerRpc() and remove the need for this move function?
There was a problem hiding this comment.
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 |
|
|
||
| static void SubmitNewPosition() | ||
| { | ||
| if (GUILayout.Button("Move Local Player")) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
+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. |
There was a problem hiding this comment.
| /// replicated on all other clients. | |
| /// replicated on all other clients. |
| /// replicated on all other clients. | |
| /// replicated on all other clients through NetworkTransform. |
UnityGio
left a comment
There was a problem hiding this comment.
Hi Fernando. Thanks for adding me for visibility, but I don't think I'm the best person to do code reviews.
This PR introduces the first Sample under the
Netcode for GameObjectspackage.Preview of how it'll appear inside Package Manager:

Preview of how it gets pulled into your project:

This sample features:
NetworkTransformwithServerauthority