33 lines
939 B
C#
33 lines
939 B
C#
|
|
using Mirror;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class VRNetworkPlayerScript : NetworkBehaviour
|
||
|
|
{
|
||
|
|
public Transform headTransform;
|
||
|
|
public VRPlayerRig vrPlayerRig;
|
||
|
|
private void Awake()
|
||
|
|
{
|
||
|
|
DontDestroyOnLoad(gameObject);
|
||
|
|
}
|
||
|
|
public override void OnStartLocalPlayer()
|
||
|
|
{
|
||
|
|
// create a link to local vr rig, so that rig can sync to our local network players transforms
|
||
|
|
vrPlayerRig = GameObject.FindFirstObjectByType<VRPlayerRig>();
|
||
|
|
vrPlayerRig.localVRNetworkPlayerScript = this;
|
||
|
|
|
||
|
|
}
|
||
|
|
// a static global list of players that can be used for a variery of features, one being enemies
|
||
|
|
public readonly static List<VRNetworkPlayerScript> playersList = new List<VRNetworkPlayerScript>();
|
||
|
|
|
||
|
|
public override void OnStartServer()
|
||
|
|
{
|
||
|
|
playersList.Add(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void OnStopServer()
|
||
|
|
{
|
||
|
|
playersList.Remove(this);
|
||
|
|
}
|
||
|
|
}
|