Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by juhalah · Nov 16, 2015 at 06:36 PM · multiplayermultiplayer-networkingsynchronizationmultiplayer networking

Having problems with multiplayer syncing

Hello everyone.

I've been trying to figure out this multiplayer syncing problem for a couple of weeks now and it seems that i can't get my head around it. In short:

  • Players sync correctly on stationary platforms.

  • Player position goes out of sync on moving platform.

You can rotate the hexagon by pressing left shift (hexagon rotates 60 degrees and is controlled by the animator). Currently it only rotates only once.

Here's the repository access

  • https://bitbucket.org/dynion/hextest

here's also small gif from the problem:

  • http://giphy.com/gifs/3o85xJDvnTSiuxM3f2

From the hosts view the client is shifting 60 degrees away and maintains it's absolute position even while both players are parented to the hexagon. Add comment

Relevant parts of the code:

Here's the controller that handle's input (isLocalPlayer) and sends command to rotate hexagon.

 public class Controller : NetworkBehaviour
 {
     CharacterController characterController;

     Transform parentHexagon;
     RaycastHit hitInfo;

     public float gravity = 21f;
     public float terminalVelocity = 20f;
     public float jumpSpeed = 12f;
     float verticalVelocity { get; set; }
     private Vector3 moveVector { get; set; }
     public float yRotation = 0f;
     public float rotationMultiplier = 1f;

     [HideInInspector]
     public float totalRotation = 1f;

     public float speed = 0f;
     float previousSpeed;

     void Awake()
     {
         characterController = GetComponent<CharacterController>();
     }

     void Update()
     {
         FindCurrentPlatform ();
         CmdHandleInput ();
     }

     // This function attaches the CharacterController (the player) to the current 
     // platform and also updates the parent when new platform is detected.
     void FindCurrentPlatform()
     {
         if (isServer) {
             if (Physics.Raycast (gameObject.transform.position, Vector3.down, out hitInfo)) {
                 if (hitInfo.transform.tag.Equals ("Platform")) {
                     parentHexagon = hitInfo.transform;
                     if (gameObject.transform.parent == null) {
                         print ("Parent set");
                         gameObject.transform.SetParent (parentHexagon);
                     }
                 }
             }
         }
     }

     void CmdHandleInput()
     {
         if (!isLocalPlayer)
             return;

         if (Input.GetButton ("Rotate"))
             CmdRotateHexagon ();

     [Command]
     void CmdRotateHexagon()
     {
         HexagonController.instance.StartRotation ();
     }

 }

And here is the controller on hexagon that starts the animator.

 public class HexagonController : NetworkBehaviour {

     public static HexagonController instance;
     public Transform hexagon;
     Animator anim;
     public bool rotate;

     void Awake()
     {
         rotate = false;
         instance = this;
     }

     // Use this for initialization
     void Start ()
     {
         anim = GetComponent<Animator> ();
     }

     // Update is called once per frame
     void Update () 
     {
     }

     public void StartRotation()
     {
         anim.SetTrigger ("Rotate");
     }

 }    

Edit: When i investigated the problem more closely, it seems that on the client side the hexagon is not rotating. That is why it seems that remote client player "goes" away from the point of rotation. However what i do not understand is that what component is missing that syncs the rotation. Ain't the Unity's networking system should take care of all this? Something is not syncing correctly.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

42 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to decide an asynchronous multiplayer solution for a turn based mobile chess game? 0 Answers

UNET NetIDs for Scene Objects Mismatched Between Client and Server 1 Answer

How can I make real-players online multiplayer games in unity just need 1-click to play like wings.io and krunker.io? 0 Answers

[Multiplayer] How to invite friends to a lobby game? 0 Answers

Multiplayer non-player object synchronization,Synchronizing Objects in Multiplayer 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges