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 CallToAdventure · Nov 20, 2014 at 02:03 PM · randomtimeeventnightday

Timed event Question

I am not sure how to approach this - I have a day/time cycle and the 24 hours cycle is a variable - in my case, 30 minutes; That means night takes 15 minutes, day - 15 minutes. Now, I want to activate a rain gameobject at night but with a random value; say, it rains at night only but every other 2 or 3 "days".

Any ideas on how to/where to start with this? Thanks in advance!

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 MrSoad · Nov 20, 2014 at 02:10 PM 0
Share

Setup a day/night bool, when you change this value use random range to deter$$anonymous$$e weather or not it will rain this night or not.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Anxo · Nov 20, 2014 at 04:29 PM

Not that this code will work as it is WUCC but this is the logic I would use.

 int rainFreeNights ;
 int nightCount = 0;
 bool itIsDayTime;
 void SetRainFreeNights(){
  rainFreeNights = Random.Range(0,3);
 }
 IEnumartor MakeItRain(){
  
     while(itIsDayTime) yield return null;
     if(nightCount == rainFreeNights){
        SetRainFreeNights();
        nightCount =0;
       RainGameObject.SetActive(true);
     }else{
         nightCount++
     }
 while(!itIsDayTime) yield return null;
 }

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
avatar image
0

Answer by White-Chocolate-Development · Nov 25, 2015 at 12:19 PM

using UnityEngine; using System.Collections;

public class TimeOfDay : MonoBehaviour {

 public float time = 0.5f;

 void Update () {
     this.transform.Rotate (Vector3.right * time * Time.smoothDeltaTime);
 }

}

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 White-Chocolate-Development · Nov 25, 2015 at 08:01 AM 0
Share

This is only for the day and night cycle. You can switch the speed by changing the float in the properties window.

avatar image White-Chocolate-Development · Nov 25, 2015 at 08:04 AM 0
Share

For the rain you can create a var called days and make it a random setting the range to be from 2-3. Then for what ever number the var days is that is when it will rain.

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

29 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

Related Questions

How to impliment a 10 minute day clock, and tie it to a directional light rotation. 4 Answers

Unity2D Day and Night Cycle 0 Answers

Creating a script to randomize events. 1 Answer

I can't get my script to work I get an error. [Please Help!] 0 Answers

How do you access the "Auto Time" or "Network-Based Time" on Android? 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