Search Unity

Multiplayer THIRD PERSON CHARACTER SPINE ROTATION PROBLEM

Discussion in 'Multiplayer' started by guillermofernandezcadarso, Jun 9, 2018.

  1. guillermofernandezcadarso

    guillermofernandezcadarso

    Joined:
    Apr 13, 2018
    Posts:
    5
    Hi guys!, Im making a ThirdPerson Game, and now im rotating the body spine to the cam forward direction, in single player works fine but in Multiplayer works like this video: -->
    <--- i dont know if this issue is caused by the network transform, network transform child or the client - command- rpc comunication, anybody can help me?
    i have this configuration in script and i´ve uploaded a screenshot of the components in the inspector code.JPG :




    Code (CSharp):
    1. void LateUpdate()
    2. {
    3. if (weaponHandler)
    4. {
    5. if (weaponHandler.currentWeapon)
    6. {
    7. if (aiming)
    8. if (!isLocalPlayer)
    9. return;
    10. PositionSpine();
    11. }
    12. }
    13. }
    14.  
    15. //Postions the spine when aiming
    16. void PositionSpine()
    17. {
    18. if (!spine || !weaponHandler.currentWeapon || !TPSCamera)
    19. return;
    20.  
    21. Transform mainCamT = TPSCamera.transform;
    22. Vector3 mainCamPos = mainCamT.position;
    23. Vector3 dir = mainCamT.forward;
    24. Ray ray = new Ray(mainCamPos, dir);
    25. Debug.DrawRay(mainCamPos, dir*10, Color.green);
    26.  
    27. //spine.LookAt(ray.GetPoint(50));
    28. clientToCmdPositionSpine(ray.GetPoint(50));
    29.  
    30. Vector3 eulerAngleOffset = weaponHandler.currentWeapon.userSettings.spineRotation;
    31. //spine.Rotate(eulerAngleOffset);
    32. }
    33.  
    34.  
    35. [Client]
    36. public void clientToCmdPositionSpine(Vector3 rayPoint)
    37. {
    38. CmdPositionSpine(rayPoint);
    39.  
    40.  
    41. }
    42.  
    43. [Command]
    44. void CmdPositionSpine(Vector3 rayPoint)
    45. {
    46. //Apply it to all other clients
    47. RpcPositionSpine(rayPoint);
    48. }
    49.  
    50. [ClientRpc]
    51. void RpcPositionSpine(Vector3 rayPoint)
    52. {
    53. spine.LookAt(rayPoint);
    54. }

    Thank so much!

    alt text
     
  2. guillermofernandezcadarso

    guillermofernandezcadarso

    Joined:
    Apr 13, 2018
    Posts:
    5
    I need help with this!!