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 /
This question was closed Oct 16, 2015 at 01:59 PM by RoofTurkey for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by RoofTurkey · Oct 16, 2015 at 11:44 AM · c#networkingtransformsynchronization

How to get transform syncing over network to work?

I tried to get a simple change in camera position to work over the network. My goal is that the client can push a UI button to switch the cameras position and rotation. As it is now, it works locally but it doesn't sync the position and rotation over the network. After trying a lot of different things, I figured it would be best to ask the community here.

The code that should handle this is: using UnityEngine; using System.Collections; using UnityEngine.Networking;

 public class CameraViews : NetworkBehaviour {
     
     public Transform view1;
     public Transform view2;
     public Transform view3;
     public Transform view4;
     [SyncVar] int chosenView = 0;
 
     void Update () {
         switch (chosenView) {
         case 0:
             transform.position = view1.position;
             transform.rotation = view1.rotation;
             break;
         case 1:
             transform.position = view2.position;
             transform.rotation = view2.rotation;
             break;
         case 2:
             transform.position = view3.position;
             transform.rotation = view3.rotation;
             break;
         case 3:
             transform.position = view4.position;
             transform.rotation = view4.rotation;
             break;
         }
     }
 
     [Command] public void CmdCamera1 () {
         chosenView = 0;
     }
 
     [Command] public void CmdCamera2 () {
         chosenView = 1;
     }
 
     [Command] public void CmdCamera3 () {
         chosenView = 2;
     }
 
     [Command] public void CmdCamera4 () {
         chosenView = 3;
     }
 }

The camera has a Network Identity component attached as well with local authority turned on and server only turned off.

Hopefully it's an easy fix, but I'm just overlooking it now. Therefore any help is much appreciated.

Comment
Add comment · Show 9
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 meat5000 ♦ · Oct 16, 2015 at 11:55 AM 0
Share

https://www.youtube.com/watch?v=NLnzlwCRjgc

Start here :) Its a good watch (a bit slow but a good watch).

avatar image RoofTurkey meat5000 ♦ · Oct 16, 2015 at 12:19 PM 0
Share

I followed the tutorial, changed the code to this:

 using System.Collections;
     
     public class CameraViews : $$anonymous$$onoBehaviour {
         
         public Transform view1;
         public Transform view2;
         public Transform view3;
         public Transform view4;
     
         public void Camera1 () {
             transform.position = view1.position;
             transform.rotation = view1.rotation;
         }
     
         public void Camera2 () {
             transform.position = view2.position;
             transform.rotation = view2.rotation;
         }
     
         public void Camera3 () {
             transform.position = view3.position;
             transform.rotation = view3.rotation;
         }
     
         public void Camera4 () {
             transform.position = view4.position;
             transform.rotation = view4.rotation;
         }
     }

Added a Network Transform to the camera, set up to sync the Transform. But still no succes unfortunately...

Edit: I just found out that when I move the camera through the scene view, it does sync properly with the clients.

avatar image meat5000 ♦ RoofTurkey · Oct 16, 2015 at 12:38 PM 0
Share

Shouldnt your script still derive from NetworkBehaviour, still?

Show more comments

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by RoofTurkey · Oct 16, 2015 at 02:25 PM

The solution for me was to make the camera selector client the host, so the full authority over the objects was already there. For more information see the comments on the question.

Comment
Add comment · Share
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

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

UNET Health isn't syncing 1 Answer

Synchronization object animation motion (NavMeshAgent) 0 Answers

Unity Networking synchronize 3DText's 1 Answer

Best way to synchronize projectile transform in networked game? 1 Answer

How can I get objects with local authority in my scene to update their positions when running networked? 1 Answer


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