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 Trassan · Jun 06, 2016 at 02:20 PM · randomloadingseed

How to generate a random seed at a 24 hour interval

Hello!

My game is played locally and I can generate a map with a random seed value. I want my users to all have the same seed and after 24 hours the seed changes. So that everybody can play the same map and send in their high scores. How can i randomize a seed every 24 hours? How do i make sure that different time zones still apply to the 24 hour seed?

I do not have a server or something similar that can run and change the seed. The game is only played locally on the clients computer except from sending in a high score after each level.

Thanks in advance

Comment
Add comment · Show 2
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 Hellium · Jun 06, 2016 at 02:22 PM 0
Share

When generating the seed, store it somewhere (file / playerprefs / ...), along the date the seed has been created.

When you must use the seed, check if it has "expired" (ie : Time.time - saveTime > 3600 * 24)

EDIT : If all the players must play on a same map the same day, you will have to get the date from somewhere (ins$$anonymous$$d of Time.time). $$anonymous$$aybe, you can have a solution using System.DateTime.UtcNow

https://msdn.microsoft.com/en-us/library/system.datetime.utcnow(v=vs.110).aspx

avatar image Mmmpies · Jun 06, 2016 at 08:12 PM 0
Share

Depends how much you're worried about users changing the date on their device.

  using UnityEngine;
  using System.Collections;
  using System;
  
  public class UTC: $$anonymous$$onoBehaviour 
  {
      void Start()
      {
          print (DateTime.UtcNow);
      }
  }

Should show the current device date/time in UTC but it's open to exploits.

 var url = "http://mytimeserver/gettime";
 var dateTime : System.DateTime;
  
 function Start () {
     var www : WWW = new WWW (url);
  
     // Wait for download to complete
     yield www;
    
     dateTime = DateTime.Parse(www.text);
 }

Should work (although I googled that!) if you have a reliable time server you can request from.

Just poll the server in a Start() and have the game keep track of time from there.

$$anonymous$$inda off topic but I'd also change the tick over time for the maps, if you always start at the same time some time zones will have a natural advantage.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Eno-Khaon · Jun 06, 2016 at 08:26 PM

There's a lot of good info at Microsoft's page regarding time zones and relative time.

If you wish to make your time zone the baseline, for example, determine the time offset for it relative to UTC (the absolute baseline, in this case), then use that as the basis for a second time conversion for the player.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to change perlin noise seed? 1 Answer

How to save a random seed to a playerpref 2 Answers

Set Random.seed for noise generator 1 Answer

GLSL: Get current time in millis 1 Answer

How to call a user input variable in another script. 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