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 miha4406jp · Oct 19, 2021 at 12:40 PM · photonpun

[pun] Vector3 synh problem

Hello. I need to sync 2 values:

 public Vector3[] actSkillTrg = new Vector3[4];  //active skill target(s)  
 public int skillCD = 0;  //active skill cooldown
 

I can't sych GameObjects, so I use Vector3 to define targets. So I use OnPhotonSerializeView to synh both. Then I have this in OnDisable():

 if (bGoldGet) { 
             gameObject.GetComponent<stats>().actSkillTrg[0] = new Vector3(3f,3f,3f);  //3rd player himself
             gameObject.GetComponent<stats>().skillCD = 3;
         }
 bGoldGet = false;

and this in GoldControl():

 public void p3GoldGet()
     {
         if (pl3.GetComponent<stats>().actSkillTrg[0] != Vector3.down)
         {
             print("pl3 gets gold!");
             pl3.GetComponent<stats>().gold++;
 
             pl3.GetComponent<stats>().actSkillTrg[0] = Vector3.down;
         }
 
         if (movEnd && pl3.GetComponent<stats>().skillCD!=0) { pl3.GetComponent<stats>().skillCD--; }        
     }

Problem is: int skillCD works fine, but Vector3[] actSkillTrg isn't synchronizing. Like if I put "print(pl3.GetComponent().actSkillTrg[0]);" in Update() it always prints "(0,-1.0,0)" on Host's pc, but prints (3.0,3.0,3.0) on Client's. Why could it be??

I use some invoke delay between OnDisable() and GoldControl().

Comment
Add comment · Show 13
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 Captain_Pineapple · Oct 19, 2021 at 12:52 PM 0
Share

where is the code where you actually sync your stuff?


In general you should make one consideration when implementing sync: Does the value change often (multiple times per second) or only a few times once every few seconds?

if the latter is the case do not use OnPhotonSerializeView. Just use an RPC. The latter is easier to implement for now-and-then sync calls - especially when it comes down to saving bandwidth.

avatar image miha4406jp Captain_Pineapple · Oct 19, 2021 at 01:13 PM 0
Share

alt text

new-bitmap-image.jpg (233.7 kB)
avatar image Captain_Pineapple miha4406jp · Oct 19, 2021 at 02:36 PM 0
Share

are you sure that the client never sets a value on it's own and that it only uses the stream values?

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by miha4406jp · Oct 22, 2021 at 09:20 PM

Well, I checked literally everything, but problem was in PhotonView itself.

Changing PhotonView option from "Reliable delta compressed" to "Unreliable on change" fixed issue.

If anybody has explanation, I'd like to hear.

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

133 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

Related Questions

,How do I transfer photon network ownership to another player? 1 Answer

Can't use Photon PUN on existing project. 0 Answers

PhotonNetwork.GetRoomList() output = 0 1 Answer

How to update Unity project from Photon Unity Networking v1 to v2 (PUN to PUN 2) 1 Answer

Photon PUN 2 Not working 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