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 marases · Jul 01, 2012 at 02:31 AM · rotation

Rotating Sun?

Hello im quite noob at Unity but i have a handle on the programming part, just wondering how i can make a sun (light) rotate areoung a terain.. Kinda like the sun rotating around the earth, so i wanna create the sense of dat and night... And also can we make this dynamic so i can apply the code somehow to any object so that it rotates around in the same way. Remember RotateAround wont work, because i have rectangular terrain..

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

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Chimera3D · Jul 01, 2012 at 02:35 AM

Okay this won't be a dynamic day/night system but if you just want to rotate a directional light couldn't you just use a simple animation? Window > Animation, select the light, hit the record icon, record your animation, loop it, hit play, done...

EDIT: Here's a code.

 var dayLength : float;
 var rotationSpeed : float;
 
 function Update () {
     
      rotationSpeed = Time.deltaTime / dayLength;
      
      transform.Rotate(0, rotationSpeed ,0);
 
 }
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 marases · Jul 01, 2012 at 02:39 AM 0
Share

But the issues is that i want to set the time taken, etc... I want code. :)

avatar image marases · Jul 01, 2012 at 03:14 AM 0
Share

Thanks, only 1 issues, its just spinning its not moving around the terrain.. so would i use RotateAround?? If so how?

avatar image Chimera3D · Jul 11, 2012 at 01:35 AM 0
Share

Why does it need to move around the terrain?

avatar image
0

Answer by Eric5h5 · Jul 01, 2012 at 02:36 AM

You don't have to actually move the light, you can just rotate it by using Transform.Rotate. Since it's a directional light it doesn't matter where it is, only in what direction it's pointing.

Comment
Add comment · Show 1 · 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 marases · Jul 01, 2012 at 02:40 AM 0
Share

But it's rotating a rectangle so it cant rotate in a circle so to speak but rather a oval.

avatar image
0

Answer by RCraig · Jul 11, 2012 at 05:07 AM

Use iTween on your light with an oval path using a looktarget. Create your path in an oval shape around your terrain and name it, create an empty game object at the center of your terrain, and set the looktarget transform in the iTweenEvent to the empty game object.

  • *Play Automatically

  • Event Type: MoveTo

  • Path: The named path you created

  • looktarget: transform: empty game object

  • time: How many seconds you want a whole day/night cycle to last

  • easetype: linear

  • looptype: loop

Leave everything else unchecked. Then just make your actual visible object a child of the light and zero its transform. Hit play and you should have a sun rotating around your world, with the directional light rotating accordingly.

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 Ingen · Jul 11, 2012 at 04:04 PM

Hy

take a look at this

http://answers.unity3d.com/questions/56379/can-i-ask-for-a-daynight-cycle-script-for-free.html

http://www.youtube.com/watch?v=zxIyZzieFqE

some time a shoot on google can help

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

8 People are following this question.

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

Related Questions

Temporary Rotation 2 Answers

Issues rotating around transform.up 2 Answers

Flip over an object (smooth transition) 3 Answers

change just z axis angle 1 Answer

What is wrong with this script? 2 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