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 12boulla · Dec 27, 2015 at 02:30 PM · androidmultiplayergoogle play gamesseed

How to make randomly generated floats the same across multiplayer? (GPGS)

Is there any way to make randomly generated floats the same in different instances of a game in multiplayer? I am using Google Play Games Services to do real time multiplayer in my android app and there are cubes that are randomly instantiated. However, I need each opponent on multiplayer to have the cubes in the same place as eachother.

alt text

These cubes get randomly generated at the start, but must be the same for people on multiplayer. For example, my game allows two people to play eachother. Both of them need to see the cubes in the same place. Is there any way to do this?

Any help is greatly appreciated, thanks.

help.png (18.8 kB)
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

1 Reply

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

Answer by tanoshimi · Dec 27, 2015 at 03:04 PM

By definition, you can't separately generate two random values and expect them to be the same. So, you either need to generate the random value only in one place (on a server, or one particular client) and then send the value to all clients. Or, you need to not have a truly "random" value, but one which is controllable: on the game start you could set a common seed value among all clients and use that to seed a series of numbers on all clients by using a common algorithm.

Comment
Add comment · Show 3 · 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 12boulla · Dec 27, 2015 at 03:09 PM 0
Share

Thanks for the answer! Do you know how I would set the values on one client and send those values to the other client?

avatar image tanoshimi · Dec 27, 2015 at 03:36 PM 0
Share

I'd have some sort of lobby system - the first player to join the game becomes the "server". It is on their instance that all game-specific values are generated. These are then sent to all the other clients using exactly the same methods that you use for network play within the game.

avatar image 12boulla · Dec 27, 2015 at 03:37 PM 0
Share

Thanks for the help @tanoshimi

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

49 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

Related Questions

Using Random.seed to sync random generation in multiplayer (android GPGS) 0 Answers

Any good/detailed Google Play Games Real Time Multiplayer setup tutorial for android? 6 Answers

GPGS - How To Cancel Matchmaking Properly? 1 Answer

GPGS - Start the match with only even numbers of players 0 Answers

How to set Master Server for Local Multiplayer 0 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