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 /
avatar image
0
Question by SPOTNINJADUD7890 · May 09, 2017 at 05:44 AM · c#unity 5networkingnetworkphoton

Photon wont sync for the masterclient.

I am trying to make this box so that only one player can use it at a time. Now this works if a client that is NOT the master client tries to open it when the master client has it open, but if the other client has it open the bool isn't synced to the master client. I have been stumped for like 5 hours and i need this to keep working. Please help.

The thing for changing the chest opened bool is on another script.

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 
 public class Inv_Man : MonoBehaviour {
 
     public GameObject ChestOpener;
     public bool Chestopen= false;
     //armour
     public GameObject LHelmObject;
     public bool LHelmObjAct = false;
     public GameObject LChestObject;
     public bool LChestObjAct = false;
     public GameObject LLegsObject;
     public bool LLegsObjAct = false;
     public GameObject LBootsObject;
     public bool    LBootsObjAct = false;
     public GameObject IHelmObject;
     public bool    IHelmObjAct = false;
     public GameObject IChestObject;
     public bool IChestObjAct = false;
     public GameObject ILegsObject;
     public bool ILegsObjAct = false;
     public GameObject IBootsObject;
     public bool IBootsObjAct = false;
     //spells
 
     public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
         if (stream.isWriting) {
             stream.SendNext (Chestopen);
             stream.SendNext (LHelmObjAct);
             stream.SendNext (LChestObjAct);
             stream.SendNext (LLegsObjAct);
             stream.SendNext (LBootsObjAct);
             stream.SendNext (IHelmObjAct);
             stream.SendNext (IChestObjAct);
             stream.SendNext (ILegsObjAct);
             stream.SendNext (IBootsObjAct);
         } else {
             Chestopen = (bool)stream.ReceiveNext();
             LHelmObjAct = (bool)stream.ReceiveNext();
             LChestObjAct = (bool)stream.ReceiveNext();
             LLegsObjAct = (bool)stream.ReceiveNext();
             LBootsObjAct = (bool)stream.ReceiveNext();
             IHelmObjAct = (bool)stream.ReceiveNext();
             IChestObjAct = (bool)stream.ReceiveNext();
             ILegsObjAct = (bool)stream.ReceiveNext();
             IBootsObjAct = (bool)stream.ReceiveNext();
         }
     }
         
     void Start () {
         LHelmObject = GameObject.Find("UI").transform.FindChild("BoxPanel").FindChild("Whitepanel").FindChild("L_Hat").gameObject;
         LChestObject = GameObject.Find("UI").transform.FindChild("BoxPanel").FindChild("Whitepanel").FindChild("L_Chest").gameObject;
         LLegsObject = GameObject.Find("UI").transform.FindChild("BoxPanel").FindChild("Whitepanel").FindChild("L_Legs").gameObject;
         LBootsObject = GameObject.Find("UI").transform.FindChild("BoxPanel").FindChild("Whitepanel").FindChild("L_Boot").gameObject;
         IHelmObject = GameObject.Find("UI").transform.FindChild("BoxPanel").FindChild("Whitepanel").FindChild("I_Hat").gameObject;
         IChestObject = GameObject.Find("UI").transform.FindChild("BoxPanel").FindChild("Whitepanel").FindChild("I_Chest").gameObject;
         ILegsObject = GameObject.Find("UI").transform.FindChild("BoxPanel").FindChild("Whitepanel").FindChild("I_Legs").gameObject;
         IBootsObject = GameObject.Find("UI").transform.FindChild("BoxPanel").FindChild("Whitepanel").FindChild("I_Boots").gameObject;
         //buttonlisteneradds
         LHelmObject.GetComponent<Button>().onClick.AddListener(LHelmButton);
         LChestObject.GetComponent<Button>().onClick.AddListener(LChestButton);
         LLegsObject.GetComponent<Button>().onClick.AddListener(LLegsButton);
         LBootsObject.GetComponent<Button>().onClick.AddListener(LBootButton);
         IHelmObject.GetComponent<Button>().onClick.AddListener(IHelmButton);
         IChestObject.GetComponent<Button>().onClick.AddListener(IChestButton);
         ILegsObject.GetComponent<Button>().onClick.AddListener(ILegsButton);
         IBootsObject.GetComponent<Button>().onClick.AddListener(IBootsButton);
         //contentchoosing
         if (Random.value < 0.5f) {
             LHelmObjAct = true;
         }
         else {
             LHelmObjAct = false;
         }
         if (Random.value < 0.5f) {
             LChestObjAct = true;
         }
         else {
             LChestObjAct = false;
         }
         if (Random.value < 0.5f) {
             LLegsObjAct = true;
         }
         else {
             LLegsObjAct = false;
         }
         if (Random.value < 0.5f) {
             LBootsObjAct = true;
         }
         else {
             LBootsObjAct = false;
         }
         if (Random.value < 0.5f) {
             IHelmObjAct = true;
         }
         else {
             IHelmObjAct = false;
         }
         if (Random.value < 0.5f) {
             IChestObjAct = true;
         }
         else {
             IChestObjAct = false;
         }
         if (Random.value < 0.5f) {
             ILegsObjAct = true;
         }
         else {
             ILegsObjAct = false;
         }
         if (Random.value < 0.5f) {
             IBootsObjAct = true;
         }
         else {
             IBootsObjAct = false;
         }
     }
     public void UPDATECONTENTS(){
         if (LHelmObjAct == true) {
             LHelmObject.SetActive (true);
         } else {
             LHelmObject.SetActive (false);
         }
         if (LChestObjAct == true) {
             LChestObject.SetActive (true);
         } else {
             LChestObject.SetActive (false);
         }
         if (LLegsObjAct == true) {
             LLegsObject.SetActive (true);
         } else {
             LLegsObject.SetActive (false);
         }
         if (LBootsObjAct == true) {
             LBootsObject.SetActive (true);
         } else {
             LBootsObject.SetActive (false);
         }
         if (IHelmObjAct == true) {
             IHelmObject.SetActive (true);
         } else {
             IHelmObject.SetActive (false);
         }
         if (IChestObjAct == true) {
             IChestObject.SetActive (true);
         } else {
             IChestObject.SetActive (false);
         }
         if (ILegsObjAct == true) {
             ILegsObject.SetActive (true);
         } else {
             ILegsObject.SetActive (false);
         }
         if (IBootsObjAct == true) {
             IBootsObject.SetActive (true);
         }else{
             IBootsObject.SetActive (false);
         }
     }
     //spells
     //armour
     public void LHelmButton(){
         ChestOpener.GetComponent<PlayerHealth> ().equipLHelm();
         LHelmObjAct = false;
         UPDATECONTENTS ();
     }
     public void LChestButton(){
         ChestOpener.GetComponent<PlayerHealth> ().equipLChest();
         LChestObjAct = false;
         UPDATECONTENTS ();
     }
     public void LLegsButton(){
         ChestOpener.GetComponent<PlayerHealth> ().equipLLegs();
         LLegsObjAct = false;
         UPDATECONTENTS ();
     }
     public void LBootButton(){
         ChestOpener.GetComponent<PlayerHealth> ().equipLBoots();
         LBootsObjAct = false;
         UPDATECONTENTS ();
     }
     public void IHelmButton(){
         ChestOpener.GetComponent<PlayerHealth> ().equipIHelm();
         IHelmObjAct = false;
         UPDATECONTENTS ();
     }
     public void IChestButton(){
         ChestOpener.GetComponent<PlayerHealth> ().equipIChest();
         IChestObjAct = false;
         UPDATECONTENTS ();
     }
     public void ILegsButton(){
         ChestOpener.GetComponent<PlayerHealth> ().equipILegs();
         ILegsObjAct = false;
         UPDATECONTENTS ();
     }
     public void IBootsButton(){
         ChestOpener.GetComponent<PlayerHealth> ().equipIBoots();
         IBootsObjAct = false;
         UPDATECONTENTS ();
     }
 }
 

`

Comment
Add comment · Show 1
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 ChristianSimon · May 15, 2017 at 03:53 AM 0
Share

Hi,

is this script added to the PhotonView's observed components?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by achitimallix0102316 · Dec 24, 2018 at 11:02 PM

Hi, I am using PhotonPUN and Unity.. I have a scene where multiple players can join, and interact with some objects in the scene. All these intractable objects are PhotonView Objects, that are supposed to sync both Position and Rotation.

Both the Clients are able to see these objects, that I spawn later. But the update of Transform(Pos,Rot) is only working from Master to Non-Master clients, But when a non Master client moves these objects, the Master does not see the updates. These PhotonView objects are in the same Resources folder as the PlayerPrefabs.

Any thing that is attached to PlayerPrefab is visible to both clients.. Anything that is spawned and added using the PhotonNetwork.Instantiate(prefabName, childTransform.position, randAng, 0) are only syncing from Master to other clinet but not vice versa.

My problem is related to are similar to yours.. Have you found the solution to this? If so please let me know..

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

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

362 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 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 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 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 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 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 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 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 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

Switching weapons in PhotonNetwork 1 Answer

Photon Network instantiate problem when Master changes 0 Answers

Can i Call Additive Scene On Network 1 Answer

Photon network problem 2 Answers

Photon Networking - Synchronization problem 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