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 /
  • Help Room /
avatar image
0
Question by Doctor_Uair · Oct 23, 2015 at 12:25 PM · c#rotation

how to set a rotation without it constantly rotating?

I'm trying to set an object's rotation without it constantly rotating. Say there's a float for the rotation's value, if that float is at 90, I want the object to stay at 90 degrees, not rotate 90 degrees constantly causing a headache to anyone who sees it. I'm coding in C# so if it's possible you can help me in that language I'd appreciate it, trying to keep things constant.

!!!EDIT 10-23-2015!!! I'm trying to make the object's rotation relative to the minute of the hour.

!!!EDIT 11-3-2015!!! Okay, scratch the minute of day thing, I need it relative to real time.

Comment
Add comment · Show 3
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 toromano · Oct 23, 2015 at 12:38 PM 0
Share

I guess you used someting like this:

 transform.Rotate(Vector3.right * Time.deltaTime);

what you need is:

    transform.rotation = Quaternion.Euler(0, 30, 0);
avatar image Doctor_Uair toromano · Oct 23, 2015 at 07:11 PM 0
Share

That didn't quite work, but it's closer than I was before

avatar image toromano Doctor_Uair · Oct 23, 2015 at 07:28 PM 0
Share

Do you need something like : float speed = 10.0f; float targetYAngle = 30; transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0, targetYAngle, 0), Time.time * speed);

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by DiegoSLTS · Oct 23, 2015 at 12:46 PM

You're probably changing the rotation inside the Update or LateUpdate methods, just move the code somewhere that's called only once. If this is not your case then share the code you're using.

If you want a smooth rotation you can use a coroutine and the Rotate method, or do it in Update but inside an if that checks if the object needs to be rotated.

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 Doctor_Uair · Oct 23, 2015 at 06:51 PM 0
Share

Forgot to mention it early, I'm trying to make it change every so and so real life $$anonymous$$utes. I'll try a little something like that and if it doesn't work I'll try Toromano's method

avatar image
0

Answer by Statement · Oct 24, 2015 at 12:11 AM

Sounds like you want to make a clock (code)?

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 Doctor_Uair · Nov 04, 2015 at 06:53 AM 0
Share

Somewhat, but ins$$anonymous$$d of an object, I want to rotate a light, and I want it to be as close to real time as possible, so if it's dark where the player is it's night where the player is it's night in game or day where the player is means day in game.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Instantiated Object Has Wrong Rotation 0 Answers

Freeze rotation X but rotation Z, how can I do this? 0 Answers

Struggling to get the rotation the player is moving in. 1 Answer

Rotation starts freaking out when I put my cursor on it. 1 Answer

Rotated object raycasting in wrong directions!!? 3 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