Search Unity

[SOLVED] HLAPI: Error with Sync Transform & Character Controller

Discussion in 'Multiplayer' started by rob_vld, Jun 24, 2015.

  1. rob_vld

    rob_vld

    Joined:
    Jul 9, 2013
    Posts:
    191
    HLAPI, C#

    I have a server - client connection that spawns a playerPrefab... both client and server playerObject has this attached:



    As soon as i try to move the character on the client this message gets spammed at the server - There is no movement.
    (Note that i had the same output by manually moving the character without a CC attached and set to Sync Transform)

    ServerSide:

    Code (CSharp):
    1.  
    2. NullReferenceException: Object reference not set to an instance of an object
    3. UnityEngine.Networking.NetworkTransform.HandleTransform (UnityEngine.Networking.NetworkMessage netMsg) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkTransform.cs:1047)
    4. UnityEngine.Networking.NetworkConnection.HandleMessage (System.Collections.Generic.Dictionary`2 handler, UnityEngine.Networking.NetworkReader reader, Int32 receivedSize, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:301)
    5. UnityEngine.Networking.NetworkServer.InternalUpdate () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkServer.cs:652)
    6. UnityEngine.Networking.NetworkServer.Update () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkServer.cs:514)
    7. UnityEngine.Networking.NetworkIdentity.UNetStaticUpdate () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkIdentity.cs:706)

    ClientSide: Manual Movement by the editor

    Code (CSharp):
    1. IndexOutOfRangeException: NetworkReader:ReadByte out of range:NetBuf sz:14 pos:14
    2. UnityEngine.Networking.NetBuffer.ReadByte () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkBuffer.cs:35)
    3. UnityEngine.Networking.NetworkReader.ReadUInt32 () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkReader.cs:201)
    4. UnityEngine.Networking.NetworkReader.ReadSingle () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkReader.cs:273)
    5. UnityEngine.Networking.NetworkReader.ReadVector3 () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkReader.cs:346)
    6. UnityEngine.Networking.NetworkTransform.UnserializeModeCharacterController (UnityEngine.Networking.NetworkReader reader, Boolean initialState) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkTransform.cs:630)
    7. UnityEngine.Networking.NetworkTransform.OnDeserialize (UnityEngine.Networking.NetworkReader reader, Boolean initialState) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkTransform.cs:383)
    8. UnityEngine.Networking.NetworkIdentity.OnUpdateVars (UnityEngine.Networking.NetworkReader reader, Boolean initialState) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkIdentity.cs:534)
    9. UnityEngine.Networking.ClientScene.OnUpdateVarsMessage (UnityEngine.Networking.NetworkMessage netMsg) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/ClientScene.cs:591)
    10. UnityEngine.Networking.NetworkConnection.HandleMessage (System.Collections.Generic.Dictionary`2 handler, UnityEngine.Networking.NetworkReader reader, Int32 receivedSize, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:301)
    11. UnityEngine.Networking.NetworkClient.Update () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkClient.cs:472)
    12. UnityEngine.Networking.NetworkClient.UpdateClients () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkClient.cs:686)
    13. UnityEngine.Networking.NetworkIdentity.UNetStaticUpdate () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkIdentity.cs:707)
    14.  
     
    Last edited: Jun 25, 2015
  2. rob_vld

    rob_vld

    Joined:
    Jul 9, 2013
    Posts:
    191
    My own mistake, i did not set the playerControllerID with the same value at both client and server.
    :(
     
  3. atgczcl

    atgczcl

    Joined:
    Aug 6, 2013
    Posts:
    2
    try use like this(my error is gone!)
    string message = msg.ReadMessage<StringMessage>().value;

    and this (error is on, throw errors !):
    netMsg.reader.ReadString()