From 58be4d44fd1eae5c9ebb14ed05c4add033249514 Mon Sep 17 00:00:00 2001 From: MrGadget Date: Wed, 11 Sep 2019 15:07:08 -0400 Subject: [PATCH] Update SyncVars.md --- doc/articles/Classes/SyncVars.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/articles/Classes/SyncVars.md b/doc/articles/Classes/SyncVars.md index 18bc93c5b..6a1be41ec 100644 --- a/doc/articles/Classes/SyncVars.md +++ b/doc/articles/Classes/SyncVars.md @@ -20,10 +20,10 @@ public class Enemy : NetworkBehaviour [SyncVar] public int health = 100; - private void OnMouseUp() + void OnMouseUp() { NetworkIdentity ni = NetworkClient.connection.playerController; - PlayerController pc = networkIdentity.GetComponent(); + PlayerController pc = ni.GetComponent(); pc.currentTarget = gameObject; } } @@ -52,4 +52,4 @@ public class PlayerController : NetworkBehaviour } ``` -In this example, when a Player clicks on an Enemy, the networked enemy game object is assigned to `PlayerController.currentTarget`. When the player presses X, with a correct target selected, that target is passed through a Command, which runs on the server, to decrement the `Enemy.health` SyncVar. All clients will be updated with that new value. You can then have a UI on the enemy to show the current value. +In this example, when a Player clicks on an Enemy, the networked enemy game object is assigned to `PlayerController.currentTarget`. When the player presses X, with a correct target selected, that target is passed through a Command, which runs on the server, to decrement the `health` SyncVar. All clients will be updated with that new value. You can then have a UI on the enemy to show the current value.