using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem.XR; using UnityEngine.XR.Interaction.Toolkit; public class NetworkPlayer : NetworkBehaviour { public Vector2 Player1Position = new Vector2(-1f, 0); public Vector2 Player2Position = new Vector2(1f, 0); public override void OnNetworkSpawn() { //base.OnNetworkSpawn(); DisableClientInput(); } private void DisableClientInput() { if (!IsOwner && IsClient) { var clientMoveProvider = GetComponent(); var clientTurnProvider = GetComponent(); var clientControllers = GetComponentsInChildren(); var clientRays = GetComponentsInChildren(); var clientHead = GetComponentInChildren(); var clientCamera = GetComponentInChildren(); var clientAudioListener = GetComponentInChildren(); var clientLIV = GetComponent(); //var clientOVRManager = gameObject.transform.Find("OVRManager").gameObject; clientCamera.enabled = false; clientAudioListener.enabled = false; clientMoveProvider.enabled = false; clientTurnProvider.enabled = false; clientHead.enabled = false; foreach (var ray in clientRays) { ray.RaySwitch = false; } foreach (var controller in clientControllers) { controller.enabled = false; } clientLIV.enabled = false; //clientOVRManager.SetActive(false); } } private void Start() { if (IsHost) { transform.position = new Vector3(Player1Position.x, transform.position.y, Player1Position.y); } else { transform.position = new Vector3(Player2Position.x, transform.position.y, Player2Position.y); } } }