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 oliver-jones · Jun 01, 2011 at 11:54 AM · rotationtimereset

Help With Simple Rotation

I'm struggling to get my head around this, but basically - I have a ResetRotation function in where I want it to:

yield WaitForSeconds(2);

and then reset the Y rotation to '0' over time (so it looks like its animated).

How would one go about doing that?

Thanks

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
1
Best Answer

Answer by leonalchemist · Jun 01, 2011 at 01:09 PM

it's probably be better if u use the animation tab in unity, there a good basic tutorial on the unity site that shows u how to do it. check here for the videos : http://unity3d.com/support/resources/tutorials/video-animation-view

or maybe what u can do is something like this

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

in this case it says its rotates the object on the x axes by 1 degree per sec, so not sure how to get exactly what u want myself but its a start.

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 RetepTrun · Jun 01, 2011 at 05:22 PM

If you could keep track of how far you are rotating as you are doing it, then you could just rotate the same amount again but negative.

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 Anxo · Jun 01, 2011 at 05:32 PM

Check documentation on how to use RotateTwoards. Or you can use

 var reset : boolean; 
 function Update(){
 if(reset )
 {
 transform.Rotate(0,Mathf.Lerp(transform.rotation.y, 0,Time.time),0);
 }
 }

something like that would rotate it back to 0 on the y axis over 1 second whenever reset is true.

Comment
Add comment · Show 4 · 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 Anxo · Jun 01, 2011 at 05:36 PM 0
Share

to activate it you could have

reSet();

function reSet(){ reset = true; yield WaitForSeconds(1); reset = false; }

avatar image oliver-jones · Jun 07, 2011 at 11:04 AM 0
Share

This does not work, any idea why?

avatar image Joshua · Jun 07, 2011 at 12:27 PM 0
Share

Time.time starts counting at the start of the game, not at the start of this specific reset. In the reset function Anxo posted you could have var timer : float = Time.time and in the transform.Rotate replace Time.time with Time.time-timer

avatar image Anxo · Jun 08, 2011 at 10:26 PM 0
Share

@Oliver Jones when you say "This does not work, any idea why? What do you mean? does it pop out an error? link the code you tried it with, $$anonymous$$e was just an example to use as base you may not be able to copy and paste.

please link the code you tried this with.

avatar image
0

Answer by flaminghairball · Jun 07, 2011 at 01:28 PM

This is probably easiest done with a coroutine.

Typed in browser - may or may not compile ;)

 function ResetRotation(){
      var oldY : float = transform.eulerAngles.y;
      var t : float = 0.0;//animation time
      var speed : float = 1.0; //how fast you want the rotation to happen
      while(t < 1.0){ 
           transform.eulerAngles.y = Mathf.Lerp(oldY, 0.0, t); //rotate to the new position
           t += Time.deltaTime * speed;  //animate the time variable
           yield; //yield til the next frame
      }
 }

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 flaminghairball · Jun 07, 2011 at 01:28 PM 0
Share

Just call that function when you're ready to rotate back to 0, and it should handle the rest.

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

7 People are following this question.

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

Related Questions

Smooth reset rotation problem 1 Answer

Time.timeSinceLevelLoad does not reset 1 Answer

Timer not working as expected. 1 Answer

Orbit around player, but allow re-centering of camera via button press? 2 Answers

Quaternion.Slerp rotation speed increases over script life. 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