1
0
mirror of https://github.com/xiaopeng12138/MaiDXR.git synced 2024-12-11 09:45:58 +01:00
MaiDXR/Assets/Scripts/Networks/NetworkPlayer.cs
xpeng d00d192af5 bug fix
locker bug
mp haptic bug
mp hand size bug
mp endcode bug
mp decode bug
2022-08-26 22:06:45 +02:00

64 lines
2.2 KiB
C#

using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem.XR;
using UnityEngine.XR.Interaction.Toolkit;
public class NetworkPlayer : NetworkBehaviour
{
public Vector2 Player1Position = new Vector2(-0.75f, 0);
public Vector2 Player2Position = new Vector2(0.75f, 0);
public override void OnNetworkSpawn()
{
//base.OnNetworkSpawn();
DisableClientInput();
}
private void DisableClientInput()
{
if (!IsOwner)
{
var clientMoveProvider = GetComponent<ActionBasedContinuousMoveProvider>();
var clientTurnProvider = GetComponent<ActionBasedContinuousTurnProvider>();
var clientControllers = GetComponentsInChildren<ActionBasedController>();
var clientRays = GetComponentsInChildren<RayManager>();
var clientHaptics = GetComponentsInChildren<ControllerHapticManager>();
var clientHead = GetComponentInChildren<TrackedPoseDriver>();
var clientCamera = GetComponentInChildren<Camera>();
var clientAudioListener = GetComponentInChildren<AudioListener>();
var clientLIV = GetComponent<LIV.SDK.Unity.LIV>();
//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;
}
foreach (var haptic in clientHaptics)
{
Destroy(haptic);
}
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);
}
}
}