Search Unity

Network transform not working with Oculus

Discussion in 'Multiplayer' started by SgtAlvarez, Nov 8, 2018.

  1. SgtAlvarez

    SgtAlvarez

    Joined:
    Nov 14, 2017
    Posts:
    3
    Hello all,

    I am new to unity and game design in general so there's probably a few steps I'm missing but I've been trying to set up a multiplayer VR game for a few weeks. The idea of my game is that a player can join remotely to this room and play random instruments and make sound around the room. I've followed the Step by Step guide on unity for setting up the online features. So far, I've got most of things working excepts every time a new player prefab is created when someone joins the game, the previous person looses control of their HMD camera and sees what the new player sees. I can tell that the character controller is not affected because I can look through the scene and I see individual characters move around the scene independent of each other, however only one player can can see at once. I've attempted putting all the individual components for the Oculus VR under a NetworkTransformChild Script which takes no effect. Any clues what's going on?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You should post the code of how you are setting the camera to follow the player. I'm going to take a guess that in Start on some script attached to the Player object you are getting a reference to the camera and either making it a child of the player object or telling a script to follow the player. You probably just need to add something like below to fix your issue.

    Code (csharp):
    1. void Start()
    2. {
    3.     if (isLocalPlayer)
    4.     {
    5.         //Do whatever to have camera follow me here
    6.     }
    7. }
    Understand that any code you add to a networked object, including the Player object, is run on every single client. There will be lots of times you want code to only run on certain clients, on the server/host, or on the client that the Player object represents. So you need to use a lot of "isLocalPlayer", "hasAuthority", "isServer", etc, to only run code when you actually intend to run it.
     
  3. SgtAlvarez

    SgtAlvarez

    Joined:
    Nov 14, 2017
    Posts:
    3
    Hi Joe, thanks for the quick response. I'm using the OVR player controller that comes with the Oculus integration here's the code for it with the added network components
    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3. using UnityEngine.Networking;
    4.  
    5. /// <summary>
    6. /// Controls the player's movement in virtual reality.
    7. /// </summary>
    8. [RequireComponent(typeof(CharacterController))]
    9. public class OVRPlayerController : NetworkBehaviour
    10. {
    11.     /// <summary>
    12.     /// The rate acceleration during movement.
    13.     /// </summary>
    14.     public float Acceleration = 0.1f;
    15.  
    16.     /// <summary>
    17.     /// The rate of damping on movement.
    18.     /// </summary>
    19.     public float Damping = 0.3f;
    20.  
    21.     /// <summary>
    22.     /// The rate of additional damping when moving sideways or backwards.
    23.     /// </summary>
    24.     public float BackAndSideDampen = 0.5f;
    25.  
    26.     /// <summary>
    27.     /// The force applied to the character when jumping.
    28.     /// </summary>
    29.     public float JumpForce = 0.3f;
    30.  
    31.     /// <summary>
    32.     /// The rate of rotation when using a gamepad.
    33.     /// </summary>
    34.     public float RotationAmount = 1.5f;
    35.  
    36.     /// <summary>
    37.     /// The rate of rotation when using the keyboard.
    38.     /// </summary>
    39.     public float RotationRatchet = 45.0f;
    40.  
    41.     /// <summary>
    42.     /// The player will rotate in fixed steps if Snap Rotation is enabled.
    43.     /// </summary>
    44.     [Tooltip("The player will rotate in fixed steps if Snap Rotation is enabled.")]
    45.     public bool SnapRotation = true;
    46.  
    47.     /// <summary>
    48.     /// How many fixed speeds to use with linear movement? 0=linear control
    49.     /// </summary>
    50.     [Tooltip("How many fixed speeds to use with linear movement? 0=linear control")]
    51.     public int FixedSpeedSteps;
    52.  
    53.     /// <summary>
    54.     /// If true, reset the initial yaw of the player controller when the Hmd pose is recentered.
    55.     /// </summary>
    56.     public bool HmdResetsY = true;
    57.  
    58.     /// <summary>
    59.     /// If true, tracking data from a child OVRCameraRig will update the direction of movement.
    60.     /// </summary>
    61.     public bool HmdRotatesY = true;
    62.  
    63.     /// <summary>
    64.     /// Modifies the strength of gravity.
    65.     /// </summary>
    66.     public float GravityModifier = 0.379f;
    67.    
    68.     /// <summary>
    69.     /// If true, each OVRPlayerController will use the player's physical height.
    70.     /// </summary>
    71.     public bool useProfileData = true;
    72.  
    73.     /// <summary>
    74.     /// The CameraHeight is the actual height of the HMD and can be used to adjust the height of the character controller, which will affect the
    75.     /// ability of the character to move into areas with a low ceiling.
    76.     /// </summary>
    77.     [NonSerialized]
    78.     public float CameraHeight;
    79.  
    80.     /// <summary>
    81.     /// This event is raised after the character controller is moved. This is used by the OVRAvatarLocomotion script to keep the avatar transform synchronized
    82.     /// with the OVRPlayerController.
    83.     /// </summary>
    84.     public event Action<Transform> TransformUpdated;
    85.  
    86.     /// <summary>
    87.     /// This bool is set to true whenever the player controller has been teleported. It is reset after every frame. Some systems, such as
    88.     /// CharacterCameraConstraint, test this boolean in order to disable logic that moves the character controller immediately
    89.     /// following the teleport.
    90.     /// </summary>
    91.     [NonSerialized] // This doesn't need to be visible in the inspector.
    92.     public bool Teleported;
    93.  
    94.     /// <summary>
    95.     /// This event is raised immediately after the camera transform has been updated, but before movement is updated.
    96.     /// </summary>
    97.     public event Action CameraUpdated;
    98.  
    99.     /// <summary>
    100.     /// This event is raised right before the character controller is actually moved in order to provide other systems the opportunity to
    101.     /// move the character controller in response to things other than user input, such as movement of the HMD. See CharacterCameraConstraint.cs
    102.     /// for an example of this.
    103.     /// </summary>
    104.     public event Action PreCharacterMove;
    105.  
    106.     /// <summary>
    107.     /// When true, user input will be applied to linear movement. Set this to false whenever the player controller needs to ignore input for
    108.     /// linear movement.
    109.     /// </summary>
    110.     public bool EnableLinearMovement = true;
    111.  
    112.     /// <summary>
    113.     /// When true, user input will be applied to rotation. Set this to false whenever the player controller needs to ignore input for rotation.
    114.     /// </summary>
    115.     public bool EnableRotation = true;
    116.  
    117.     protected CharacterController Controller = null;
    118.     protected OVRCameraRig CameraRig = null;
    119.  
    120.     private float MoveScale = 1.0f;
    121.     private Vector3 MoveThrottle = Vector3.zero;
    122.     private float FallSpeed = 0.0f;
    123.     private OVRPose? InitialPose;
    124.     public float InitialYRotation { get; private set; }
    125.     private float MoveScaleMultiplier = 1.0f;
    126.     private float RotationScaleMultiplier = 1.0f;
    127.     private bool  SkipMouseRotation = true; // It is rare to want to use mouse movement in VR, so ignore the mouse by default.
    128.     private bool  HaltUpdateMovement = false;
    129.     private bool prevHatLeft = false;
    130.     private bool prevHatRight = false;
    131.     private float SimulationRate = 60f;
    132.     private float buttonRotation = 0f;
    133.     private bool ReadyToSnapTurn; // Set to true when a snap turn has occurred, code requires one frame of centered thumbstick to enable another snap turn.
    134.  
    135.     void Start()
    136.     {
    137.         // Add eye-depth as a camera offset from the player controller
    138.         var p = CameraRig.transform.localPosition;
    139.         p.z = OVRManager.profile.eyeDepth;
    140.         CameraRig.transform.localPosition = p;
    141.     }
    142.  
    143.     void Awake()
    144.     {
    145.         Controller = gameObject.GetComponent<CharacterController>();
    146.  
    147.         if(Controller == null)
    148.             Debug.LogWarning("OVRPlayerController: No CharacterController attached.");
    149.  
    150.         // We use OVRCameraRig to set rotations to cameras,
    151.         // and to be influenced by rotation
    152.         OVRCameraRig[] CameraRigs = gameObject.GetComponentsInChildren<OVRCameraRig>();
    153.  
    154.         if(CameraRigs.Length == 0)
    155.             Debug.LogWarning("OVRPlayerController: No OVRCameraRig attached.");
    156.         else if (CameraRigs.Length > 1)
    157.             Debug.LogWarning("OVRPlayerController: More then 1 OVRCameraRig attached.");
    158.         else
    159.             CameraRig = CameraRigs[0];
    160.  
    161.         InitialYRotation = transform.rotation.eulerAngles.y;
    162.     }
    163.  
    164.     void OnEnable()
    165.     {
    166.         OVRManager.display.RecenteredPose += ResetOrientation;
    167.  
    168.         if (CameraRig != null)
    169.         {
    170.             CameraRig.UpdatedAnchors += UpdateTransform;
    171.         }
    172.     }
    173.  
    174.     void OnDisable()
    175.     {
    176.         OVRManager.display.RecenteredPose -= ResetOrientation;
    177.  
    178.         if (CameraRig != null)
    179.         {
    180.             CameraRig.UpdatedAnchors -= UpdateTransform;
    181.         }
    182.     }
    183.  
    184.     void Update()
    185.     {
    186.         //Use keys to ratchet rotation
    187.         if (Input.GetKeyDown(KeyCode.Q))
    188.             buttonRotation -= RotationRatchet;
    189.  
    190.         if (Input.GetKeyDown(KeyCode.E))
    191.             buttonRotation += RotationRatchet;
    192.  
    193.         if (!isLocalPlayer)
    194.         {
    195.             return;
    196.         }
    197.     }
    198.  
    199.     protected virtual void UpdateController()
    200.     {
    201.         if (useProfileData)
    202.         {
    203.             if (InitialPose == null)
    204.             {
    205.                 // Save the initial pose so it can be recovered if useProfileData
    206.                 // is turned off later.
    207.                 InitialPose = new OVRPose()
    208.                 {
    209.                     position = CameraRig.transform.localPosition,
    210.                     orientation = CameraRig.transform.localRotation
    211.                 };
    212.             }
    213.  
    214.             var p = CameraRig.transform.localPosition;
    215.             if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.EyeLevel)
    216.             {
    217.                 p.y = OVRManager.profile.eyeHeight - (0.5f * Controller.height) + Controller.center.y;
    218.             }
    219.             else if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.FloorLevel)
    220.             {
    221.                 p.y = - (0.5f * Controller.height) + Controller.center.y;
    222.             }
    223.             CameraRig.transform.localPosition = p;
    224.         }
    225.         else if (InitialPose != null)
    226.         {
    227.             // Return to the initial pose if useProfileData was turned off at runtime
    228.             CameraRig.transform.localPosition = InitialPose.Value.position;
    229.             CameraRig.transform.localRotation = InitialPose.Value.orientation;
    230.             InitialPose = null;
    231.         }
    232.  
    233.         CameraHeight = CameraRig.centerEyeAnchor.localPosition.y;
    234.  
    235.         if (CameraUpdated != null)
    236.         {
    237.             CameraUpdated();
    238.         }
    239.  
    240.         UpdateMovement();
    241.  
    242.         Vector3 moveDirection = Vector3.zero;
    243.  
    244.         float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));
    245.  
    246.         MoveThrottle.x /= motorDamp;
    247.         MoveThrottle.y = (MoveThrottle.y > 0.0f) ? (MoveThrottle.y / motorDamp) : MoveThrottle.y;
    248.         MoveThrottle.z /= motorDamp;
    249.  
    250.         moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;
    251.  
    252.         // Gravity
    253.         if (Controller.isGrounded && FallSpeed <= 0)
    254.             FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f)));
    255.         else
    256.             FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate * Time.deltaTime);
    257.  
    258.         moveDirection.y += FallSpeed * SimulationRate * Time.deltaTime;
    259.  
    260.  
    261.         if (Controller.isGrounded && MoveThrottle.y <= transform.lossyScale.y * 0.001f)
    262.         {
    263.             // Offset correction for uneven ground
    264.             float bumpUpOffset = Mathf.Max(Controller.stepOffset, new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
    265.             moveDirection -= bumpUpOffset * Vector3.up;
    266.         }
    267.  
    268.         if (PreCharacterMove != null)
    269.         {
    270.             PreCharacterMove();
    271.             Teleported = false;
    272.         }
    273.  
    274.         Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 0, 1));
    275.  
    276.         // Move contoller
    277.         Controller.Move(moveDirection);
    278.         Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1));
    279.  
    280.         if (predictedXZ != actualXZ)
    281.             MoveThrottle += (actualXZ - predictedXZ) / (SimulationRate * Time.deltaTime);
    282.     }
    283.  
    284.  
    285.  
    286.  
    287.  
    288.     public virtual void UpdateMovement()
    289.     {
    290.         if (HaltUpdateMovement)
    291.             return;
    292.  
    293.         if (EnableLinearMovement)
    294.         {
    295.             bool moveForward = Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow);
    296.             bool moveLeft = Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow);
    297.             bool moveRight = Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow);
    298.             bool moveBack = Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow);
    299.  
    300.             bool dpad_move = false;
    301.  
    302.             if (OVRInput.Get(OVRInput.Button.DpadUp))
    303.             {
    304.                 moveForward = true;
    305.                 dpad_move = true;
    306.  
    307.             }
    308.  
    309.             if (OVRInput.Get(OVRInput.Button.DpadDown))
    310.             {
    311.                 moveBack = true;
    312.                 dpad_move = true;
    313.             }
    314.  
    315.             MoveScale = 1.0f;
    316.  
    317.             if ((moveForward && moveLeft) || (moveForward && moveRight) ||
    318.                 (moveBack && moveLeft) || (moveBack && moveRight))
    319.                 MoveScale = 0.70710678f;
    320.  
    321.             // No positional movement if we are in the air
    322.             if (!Controller.isGrounded)
    323.                 MoveScale = 0.0f;
    324.  
    325.             MoveScale *= SimulationRate * Time.deltaTime;
    326.  
    327.             // Compute this for key movement
    328.             float moveInfluence = Acceleration * 0.1f * MoveScale * MoveScaleMultiplier;
    329.  
    330.             // Run!
    331.             if (dpad_move || Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
    332.                 moveInfluence *= 2.0f;
    333.  
    334.             Quaternion ort = transform.rotation;
    335.             Vector3 ortEuler = ort.eulerAngles;
    336.             ortEuler.z = ortEuler.x = 0f;
    337.             ort = Quaternion.Euler(ortEuler);
    338.  
    339.             if (moveForward)
    340.                 MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * Vector3.forward);
    341.             if (moveBack)
    342.                 MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * BackAndSideDampen * Vector3.back);
    343.             if (moveLeft)
    344.                 MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.left);
    345.             if (moveRight)
    346.                 MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.right);
    347.  
    348.  
    349.  
    350.             moveInfluence = Acceleration * 0.1f * MoveScale * MoveScaleMultiplier;
    351.  
    352. #if !UNITY_ANDROID // LeftTrigger not avail on Android game pad
    353.             moveInfluence *= 1.0f + OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger);
    354. #endif
    355.  
    356.             Vector2 primaryAxis = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
    357.  
    358.             // If speed quantization is enabled, adjust the input to the number of fixed speed steps.
    359.             if (FixedSpeedSteps > 0)
    360.             {
    361.                 primaryAxis.y = Mathf.Round(primaryAxis.y * FixedSpeedSteps) / FixedSpeedSteps;
    362.                 primaryAxis.x = Mathf.Round(primaryAxis.x * FixedSpeedSteps) / FixedSpeedSteps;
    363.             }
    364.  
    365.             if (primaryAxis.y > 0.0f)
    366.                 MoveThrottle += ort * (primaryAxis.y * transform.lossyScale.z * moveInfluence * Vector3.forward);
    367.  
    368.             if (primaryAxis.y < 0.0f)
    369.                 MoveThrottle += ort * (Mathf.Abs(primaryAxis.y) * transform.lossyScale.z * moveInfluence *
    370.                                        BackAndSideDampen * Vector3.back);
    371.  
    372.             if (primaryAxis.x < 0.0f)
    373.                 MoveThrottle += ort * (Mathf.Abs(primaryAxis.x) * transform.lossyScale.x * moveInfluence *
    374.                                        BackAndSideDampen * Vector3.left);
    375.  
    376.             if (primaryAxis.x > 0.0f)
    377.                 MoveThrottle += ort * (primaryAxis.x * transform.lossyScale.x * moveInfluence * BackAndSideDampen *
    378.                                        Vector3.right);
    379.         }
    380.  
    381.         if (EnableRotation)
    382.         {
    383.             Vector3 euler = transform.rotation.eulerAngles;
    384.             float rotateInfluence = SimulationRate * Time.deltaTime * RotationAmount * RotationScaleMultiplier;
    385.  
    386.             bool curHatLeft = OVRInput.Get(OVRInput.Button.PrimaryShoulder);
    387.  
    388.             if (curHatLeft && !prevHatLeft)
    389.                 euler.y -= RotationRatchet;
    390.  
    391.             prevHatLeft = curHatLeft;
    392.  
    393.             bool curHatRight = OVRInput.Get(OVRInput.Button.SecondaryShoulder);
    394.  
    395.             if (curHatRight && !prevHatRight)
    396.                 euler.y += RotationRatchet;
    397.  
    398.             prevHatRight = curHatRight;
    399.  
    400.             euler.y += buttonRotation;
    401.             buttonRotation = 0f;
    402.  
    403.  
    404. #if !UNITY_ANDROID || UNITY_EDITOR
    405.             if (!SkipMouseRotation)
    406.                 euler.y += Input.GetAxis("Mouse X") * rotateInfluence * 3.25f;
    407. #endif
    408.  
    409.             if (SnapRotation)
    410.             {
    411.  
    412.                 if (OVRInput.Get(OVRInput.Button.SecondaryThumbstickLeft))
    413.                 {
    414.                     if (ReadyToSnapTurn)
    415.                     {
    416.                         euler.y -= RotationRatchet;
    417.                         ReadyToSnapTurn = false;
    418.                     }
    419.                 }
    420.                 else if (OVRInput.Get(OVRInput.Button.SecondaryThumbstickRight))
    421.                 {
    422.                     if (ReadyToSnapTurn)
    423.                     {
    424.                         euler.y += RotationRatchet;
    425.                         ReadyToSnapTurn = false;
    426.                     }
    427.                 }
    428.                 else
    429.                 {
    430.                     ReadyToSnapTurn = true;
    431.                 }
    432.             }
    433.             else
    434.             {
    435.                 Vector2 secondaryAxis = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);
    436.                 euler.y += secondaryAxis.x * rotateInfluence;
    437.             }
    438.  
    439.             transform.rotation = Quaternion.Euler(euler);
    440.         }
    441.     }
    442.  
    443.  
    444.     /// <summary>
    445.     /// Invoked by OVRCameraRig's UpdatedAnchors callback. Allows the Hmd rotation to update the facing direction of the player.
    446.     /// </summary>
    447.     public void UpdateTransform(OVRCameraRig rig)
    448.     {
    449.         Transform root = CameraRig.trackingSpace;
    450.         Transform centerEye = CameraRig.centerEyeAnchor;
    451.  
    452.         if (HmdRotatesY && !Teleported)
    453.         {
    454.             Vector3 prevPos = root.position;
    455.             Quaternion prevRot = root.rotation;
    456.  
    457.             transform.rotation = Quaternion.Euler(0.0f, centerEye.rotation.eulerAngles.y, 0.0f);
    458.  
    459.             root.position = prevPos;
    460.             root.rotation = prevRot;
    461.         }
    462.  
    463.         UpdateController();
    464.         if (TransformUpdated != null)
    465.         {
    466.             TransformUpdated(root);
    467.         }
    468.     }
    469.  
    470.     /// <summary>
    471.     /// Jump! Must be enabled manually.
    472.     /// </summary>
    473.     public bool Jump()
    474.     {
    475.         if (!Controller.isGrounded)
    476.             return false;
    477.  
    478.         MoveThrottle += new Vector3(0, transform.lossyScale.y * JumpForce, 0);
    479.  
    480.         return true;
    481.     }
    482.  
    483.     /// <summary>
    484.     /// Stop this instance.
    485.     /// </summary>
    486.     public void Stop()
    487.     {
    488.         Controller.Move(Vector3.zero);
    489.         MoveThrottle = Vector3.zero;
    490.         FallSpeed = 0.0f;
    491.     }
    492.  
    493.     /// <summary>
    494.     /// Gets the move scale multiplier.
    495.     /// </summary>
    496.     /// <param name="moveScaleMultiplier">Move scale multiplier.</param>
    497.     public void GetMoveScaleMultiplier(ref float moveScaleMultiplier)
    498.     {
    499.         moveScaleMultiplier = MoveScaleMultiplier;
    500.     }
    501.  
    502.     /// <summary>
    503.     /// Sets the move scale multiplier.
    504.     /// </summary>
    505.     /// <param name="moveScaleMultiplier">Move scale multiplier.</param>
    506.     public void SetMoveScaleMultiplier(float moveScaleMultiplier)
    507.     {
    508.         MoveScaleMultiplier = moveScaleMultiplier;
    509.     }
    510.  
    511.     /// <summary>
    512.     /// Gets the rotation scale multiplier.
    513.     /// </summary>
    514.     /// <param name="rotationScaleMultiplier">Rotation scale multiplier.</param>
    515.     public void GetRotationScaleMultiplier(ref float rotationScaleMultiplier)
    516.     {
    517.         rotationScaleMultiplier = RotationScaleMultiplier;
    518.     }
    519.  
    520.     /// <summary>
    521.     /// Sets the rotation scale multiplier.
    522.     /// </summary>
    523.     /// <param name="rotationScaleMultiplier">Rotation scale multiplier.</param>
    524.     public void SetRotationScaleMultiplier(float rotationScaleMultiplier)
    525.     {
    526.         RotationScaleMultiplier = rotationScaleMultiplier;
    527.     }
    528.  
    529.     /// <summary>
    530.     /// Gets the allow mouse rotation.
    531.     /// </summary>
    532.     /// <param name="skipMouseRotation">Allow mouse rotation.</param>
    533.     public void GetSkipMouseRotation(ref bool skipMouseRotation)
    534.     {
    535.         skipMouseRotation = SkipMouseRotation;
    536.     }
    537.  
    538.     /// <summary>
    539.     /// Sets the allow mouse rotation.
    540.     /// </summary>
    541.     /// <param name="skipMouseRotation">If set to <c>true</c> allow mouse rotation.</param>
    542.     public void SetSkipMouseRotation(bool skipMouseRotation)
    543.     {
    544.         SkipMouseRotation = skipMouseRotation;
    545.     }
    546.  
    547.     /// <summary>
    548.     /// Gets the halt update movement.
    549.     /// </summary>
    550.     /// <param name="haltUpdateMovement">Halt update movement.</param>
    551.     public void GetHaltUpdateMovement(ref bool haltUpdateMovement)
    552.     {
    553.         haltUpdateMovement = HaltUpdateMovement;
    554.     }
    555.  
    556.     /// <summary>
    557.     /// Sets the halt update movement.
    558.     /// </summary>
    559.     /// <param name="haltUpdateMovement">If set to <c>true</c> halt update movement.</param>
    560.     public void SetHaltUpdateMovement(bool haltUpdateMovement)
    561.     {
    562.         HaltUpdateMovement = haltUpdateMovement;
    563.     }
    564.  
    565.     /// <summary>
    566.     /// Resets the player look rotation when the device orientation is reset.
    567.     /// </summary>
    568.     public void ResetOrientation()
    569.     {
    570.         if (HmdResetsY && !HmdRotatesY)
    571.         {
    572.             Vector3 euler = transform.rotation.eulerAngles;
    573.             euler.y = InitialYRotation;
    574.             transform.rotation = Quaternion.Euler(euler);
    575.         }
    576.     }
    577.  
    578.     // Online PlayerID
    579.     public override void OnStartLocalPlayer()
    580.     {
    581.         GetComponent<MeshRenderer>().material.color = Color.blue;
    582.     }
    583. }
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Well that script isn't differentiating between clients at all. All the code there will run on every client for every player object in the scene, and if they are all referencing the same camera it looks like they will all try to move the camera. So the position of the camera will be wherever the last instance of this script moves it to. The only place I see "isLocalPlayer" mentioned is at the end of Update where it appears to be meaningless.

    If CameraRig represents the camera you're having issues with, I'd try having UpdateController return if isLocalPlayer is false and see how that changes the behavior. It is hard to say exactly what to do without understanding what is calling all the methods in that script. Maybe this script isn't intended to be used with multiple clients? no idea