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 Gamer98898 · Nov 02, 2019 at 11:40 AM · photonpun

How Could I sync a value of varibale in both device?

Actually I am working On multiplayer Project cricket game , I have made two boolean value "Cbathitside" for !photonnetwork.ismasterclient and "Sbathitside" for Photonnetwork.ismasterclient. Boolean value is equal to True only in batting side.

 Void OnTriggerEnter(Collider other)
 {
  if(other.Tag("ball"))
 {
   if (MatchTypeSelection.instance.matchType == MatchType.MultiPlayer)
                 {
                     if (MatchTypeSelection.instance.matchType == MatchType.MultiPlayer && (RotateCoin.instance.CbatHitside == true || RotateCoin.instance.SbatHitside == true))
                     {
                         randomBowlerPower = Random.Range(0, 3);
                     }
                     if (MatchTypeSelection.instance.matchType == MatchType.MultiPlayer && (RotateCoin.instance.CbatHitside == false || RotateCoin.instance.SbatHitside == false))
 
                     {
                         Batsmanhitshottiming(randomBowlerPower);
                         print("randomBolwerPower" + randomBowlerPower);
                     }
                 }
 
  }
 }

I have made BatsmanshothitTiming () for syncing that value (randomBolwerpower) in other device but it is not working please Correct me How could i make Random value should be same in both device.

  [PunRPC]
     public void Batsmanhitshottiming(int randombowlerpower)
     {
         
         randomBowlerPower = randombowlerpower;
        this.GetComponent<PhotonView>().RPC("Batsmanhitshottiming", PhotonTargets.Others,randomBowlerPower);
     }

Any help would be apperciated.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Captain_Pineapple · Nov 02, 2019 at 02:58 PM

If you want to call a function that is then called for everyone you have to go with:

 photonView.RPC("Batsmanhitshottiming", PhotonTargets.All, randomBowlerPower);

this will then call the function for everyone involved. The rpc should then be like this:

      [PunRPC]
      public void Batsmanhitshottiming(int randombowlerpower)
      {
          randomBowlerPower = randombowlerpower;
      }

Though since you post this question this makes me assume you still did not bother to read the DOCUMENTATION on photon rpcs.


Please do that before you post another question on photon rpcs. This should als kind of exmplain why your rpc does keep repeating in all your other 5 "Onclick function keeps" repeating question where you did not bother to add code. An RPC must not call itself.

Comment
Add comment · Show 2 · 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
avatar image Gamer98898 · Nov 04, 2019 at 01:27 PM 0
Share

Same thing I have written in my code as well u can check But its not working

 [PunRPC]
      public void Batsmanhitshotti$$anonymous$$g(int randombowlerpower)
      {
          
          randomBowlerPower = randombowlerpower;
         this.GetComponent<PhotonView>().RPC("Batsmanhitshotti$$anonymous$$g", PhotonTargets.Others,randomBowlerPower);
      }


avatar image Captain_Pineapple Gamer98898 · Nov 04, 2019 at 02:54 PM 1
Share

did you even read my post to the end? It says: A RPC $$anonymous$$UST NOT CALL ITSELF


you just reposted your original code where the rpc "Batsmanhitsshotti$$anonymous$$g" calls itself again.

avatar image
0

Answer by Gamer98898 · Nov 05, 2019 at 07:13 AM

@Captain_Pineapple Thanks, Yes I already read Documentation regarding Photon as well I have uploaded my code for Onclick Click function. I have noticed one thing that data is getting delayed for few nanoseconds because of this issue Gameplay is not working properly . Actually data values is syncing but after getting passed ball through batsman . Any kind of help would be apperciable

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

119 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

Related Questions

Photon Help~ for Fps Muti 0 Answers

OnConnectedToMaster() vs IsConnectedAndReady? 1 Answer

How To List Rooms (PUN 2) 1 Answer

[PUN2] Problem at pushing the other players 1 Answer

Need help with joining a room in photon? 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