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 Ben 4 · Apr 08, 2010 at 04:44 PM · rotatetimeangledegreeseasing

Rotate 90 degrees over time with Parabolic Easing.

private var rotating = false;

function RotateObject (thisTransform : Transform, degrees : Vector3, seconds : float) { if (rotating) return; rotating = true; var startRotation = thisTransform.rotation; var endRotation = thisTransform.rotation * Quaternion.Euler(degrees); var t = 0.0; //var rate = 1.0/seconds; var easeSpeed = -100; var timeHandler = 0;

 while (t < 1.0) {
     timeHandler += Time.deltaTime ;
     var rate = easeSpeed * (timeHandler * timeHandler) + (.5) ;
     //t += Time.deltaTime * rate;
     t += rate;
     thisTransform.rotation = Quaternion.Slerp(startRotation, endRotation, t);
     //print("RATE: " + rate);
     //print("TH: " + timeHandler);
     //print("T: " + Time.deltaTime);
     yield;
 }

 rotating = false;

}

Ive got this all messed up i think it is close but The

timeHandler += Time.deltaTime ;

will always return zero on the print

The idea would be for the 90 rotation to start slow, ramp up through the middle, then slow back down before resting at its +90 increment resting place.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by Eric5h5 · Apr 08, 2010 at 04:59 PM

How about

private var rotating = false;

function RotateObject (thisTransform : Transform, degrees : Vector3, seconds : float) { if (rotating) return; rotating = true;

 var startRotation = thisTransform.rotation;
 var endRotation = thisTransform.rotation * Quaternion.Euler(degrees);
 var t = 0.0;
 var rate = 1.0/seconds;

 while (t < 1.0) {
     t += Time.deltaTime * rate;
     thisTransform.rotation = Quaternion.Slerp(startRotation, endRotation, Mathf.SmoothStep(0.0, 1.0, t));
     yield;
 }

 rotating = false;

}

Forgot to say, the reason your timeHandler never goes above 0 is because you defined it as an int, so adding Time.deltaTime will do nothing (unless you were getting <= 1 fps).

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 bitch2107 · Sep 30, 2014 at 06:20 PM 0
Share

Could someone possibly translate this ^^ script into C# ?

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

No one has followed this question yet.

Related Questions

Rotate 90 over time on mouseDown 2 Answers

Rotate object in a set amount of time 1 Answer

Transform.Rotate() stuck at 90 and 270 degrees 3 Answers

Gradually Rotate Character 90 Degrees 2 Answers

rotate the object only 360degree for once 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