Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by oliver-jones · Nov 09, 2013 at 01:19 PM · animationnetworkserversync

Network - Sync Issue

Hello,

I'm playing around with networking, and I've set up a little demo scene which has a wall that rotates via:

 function Update(){
     transform.Rotate(Vector3.up, Time.deltaTime * 5);

Now, this wall rotation needs to be synced across all players, right now who ever connects will start rotating the wall, thus being out of sync.

So, I decided to let the Server player control the rotation of the wall, and then send the position to every client. I could just stick a NetworkView on it, but I want to learn about syncing.

So, I've done this:

 function Update () {
 
     if(Network.isClient){
 
         SyncedMovement();
     }
     else if(Network.isServer){
 
         transform.Rotate(Vector3.up, Time.deltaTime * 5);
     }
 
 }
 
 
 function SyncedMovement()
 {
     syncTime += Time.deltaTime;
     transform.position = Vector3.Lerp(syncStartPosition, syncEndPosition, syncTime / syncDelay);
 }
 
  var lastSynchronizationTime : float = 0f;
  var syncDelay : float = 0f;
  var syncTime : float = 0f;
  var syncStartPosition : Vector3 = Vector3.zero;
  var syncEndPosition : Vector3 = Vector3.zero;
  
 function OnSerializeNetworkView(stream : BitStream, info : NetworkMessageInfo)
 {
     var syncPosition = Vector3.zero;
     if (stream.isWriting)
     {
         syncPosition = transform.position;
         stream.Serialize(syncPosition);
     }
     else
     {
         stream.Serialize(syncPosition);
  
         syncTime = 0f;
         syncDelay = Time.time - lastSynchronizationTime;
         lastSynchronizationTime = Time.time;
  
         syncStartPosition = transform.position;
         syncEndPosition = syncPosition;
     }
 }

I've then attached a NetworkView on it, and dragged the attached script into the observer.

The wall rotates just fine on the server player, but nothing happens at all with the clients. What am I doing wrong here? I followed this tutorial:

http://www.paladinstudios.com/2013/07/10/how-to-create-an-online-multiplayer-game-with-unity/

And just replaced the Rigidbody syncs with the transforms

Comment
Add comment · Show 2
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
avatar image oliver-jones · Nov 09, 2013 at 01:26 PM 0
Share

Well ... that was silly of me, I didn't replace the transform.position, to transform.rotation

avatar image oliver-jones · Nov 09, 2013 at 01:28 PM 0
Share

It works now, but there is still a bit of lag - so I'm wondering, because the animation is linear, maybe I just need to get the rotation from the server when starting up - and then using that Quaternion to play the animation locally? Would this be a better approach?

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

16 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

Related Questions

Sync animaor of child prefab 0 Answers

Network animations 2 Answers

Network Animation Problem 1 Answer

Network : sync animations of characters 1 Answer

Sync Network Animation State 2 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