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 cristiamh · Oct 27, 2019 at 09:00 AM · scripting problem

Change the origin point position

Hello friends. Please, I need to change the origin position of a DayNightCycle to correctly cast the shadow as an emulation to the movement of the sun. This involves moving the point of origin on the x-axis but I can't find a way to achieve it in the script. Could you give me some clue?

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 lgarczyn · Oct 28, 2019 at 01:40 AM

This would certainly not involve moving the entire world, though if you want to do that, it's exactly equivalent to moving the camera, or moving an object containing the world.

To get moving shadows, rotating a directional light along with the skybox is usually enough.

Directional lights do not care about their position, so you can simply use a script that calls transform.Rotate every frame.

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 cristiamh · Nov 02, 2019 at 07:42 AM

Thanks for your answer, but I think I didn't explain myself well. I share you some grafics, please take a look. alt text


esquemaok.jpg (292.2 kB)
Comment
Add comment · Show 10 · 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 lgarczyn · Nov 02, 2019 at 07:16 PM 0
Share

You are mistaken. When a light is that far away, there is no such thing as it's position relative to you in your calculations, only its angle matters.

You can move a directional light as far as you want on the X axis, it will not change the shadows.

You can simulate a Winter sun simply adding another rotation to your directional light. Assu$$anonymous$$g the sun rises on Z, and sets on -Z, you will need a rotation on the X axis that cycles throughout the day, and one on the Y axis that depends on seasons and latitude.

avatar image cristiamh lgarczyn · Nov 02, 2019 at 11:33 PM 0
Share

Thanks again! Excuse my redaction, please, I'm not good enough with english! Well, I think the distance is not so far. We want to show how ancient comunities measure the time in Equator ...they use columns and marks on the ground. The project name is The cross of time and I need to resolve the question to move forward. Here is the code...

Vector3 distanceFromOriginVector = new Vector3(distanceFromOrigin, 200, 0);

     sun.position = distanceFromOriginVector;
     sun.rotation = Quaternion.Euler(0, -90, 0);

//..so....actually we're using aditional variables to perform the shadows with angles (orbital angle)... but after 12am the shadow is projected on he wrong side because is not realistic.//

transform.rotation = Quaternion.Euler(orbitalAngle, sunrisePosition, dayProgress);

avatar image lgarczyn cristiamh · Nov 04, 2019 at 10:43 AM 0
Share

Again, the position of the sun doesn't matter here. It might affect your shadows by millimeters, if your lights were point lights. But a directional light DOES NOT USE the position AT ALL, and it is likely what you are using now.

The 12am problem is a bit weird, and you will need to describe it more. It can be caused by a Euler lock, which can be solved by simply using a series of multiplications of AngleAxis results. For example this should work:

 transform.rotation = 
     Quaternion.AngleAxis( sunrisePosition, Vector3.up)
     * Quaternion.AngleAxis(orbitalAngle, Vector3.forward)
     * Quaternion.AngleAxis(dayProgress, Vector3.right) ;

If it doesn't, mess around with the order of the multiplication.

If you meant 12am as midnight, which is the actual meaning, then you might be complaining about seeing light despite the directional light being underground. You need to enable shadows to fix this easily, but you could also dim the sun depending on the distance from the apex, which can be calculated using

Quaternions.Angle

Show more comments

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

200 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 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

Script executing through walls 1 Answer

Issues cycling through Game objects in dictionary and activating currently selected objects script 1 Answer

How to find text value in a gameobjects list 1 Answer

Import ogg via script from non assets folder 0 Answers

If-else statement executing incorrectly in foreach loop,why? 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