Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 MoProductions · Dec 14, 2010 at 11:04 PM · quaternionangleeuleranglessmoothdamp

Quaternions, Eulers, and SmoothDampAngle

Hello everyone, glad to be on board here. Here's the issue: I have a cylinder that I need to move from a starting position/rotation to a new position/rotation over time. I've done this kind of thing in the past, but this time I've decided to take advantage of Unity's built in functionality. However, I'm new to Unity so I'm having trouble wrapping my head around the whole Quaternion/Euler thing. I've tried to start off just working with the rotation, and here's what I have so far:

private GameObject myCylinder; // this gets initalized in Start()
private Transform endCylinderTransform; // this holds the angle I want to rotate to
void SetupCylinderInfo()
{
     // this sets up the cylinders starting rotation
     Vector3 startingRotation = new Vector3(90.0f, 0.0f, 0.0f);
     myCylinder.transform.rotation = Quaternion.Euler(startingRotation);
     // I want the cylinder to rotate along the x-axis from 90 to 270 degrees
     endCylinderTransform = (Transform)Instantiate(myCylinder.transform);
     Vector3 endCylinderRot = new Vector3(270.0f, 0.0f, 0.0f);
     endCylinderTransform.rotation = Quaternion.Euler(endCylinderRot);
}

Below is the function where I try to do the rotation

float xVel = 0.0f;
void FixedUpdate()
{
     // get the angle using SmoothDampAngle.  I want to rotate it over 1 second
     float xAngle = Mathf.SmoothDampAngle(myCylinder.transform.eulerAngles.x,
                    endCylinderTransform.eulerAngles.x, ref xVel, 1f);
     Vector3 newRot = new Vector3(xAngle, 0.0f, 0.0f);
     myCylinder.transform.rotation = Quaternion.Euler(newRot);
}

Well, needless to say this isn't working. It rotates the cylinder a tiny bit but once it reaches it's end it bounces back and forth (probably because I'm not checking for the clamp). Can anyone tell me what exactly I'm doing wrong? I hope that once I get this sorted out I'll be able to deal with the translation in a similar way but first things first.

Thank you. If you need any other info please let me know. -Mo

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

0 Replies

· Add your reply
  • Sort: 

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

How do I clamp the Z-Axis Rotation for this code? 1 Answer

quaternion.eulerAngles 1:1 angle conversion 1 Answer

Euler angle rotation in self space problem. 1 Answer

follow an object's x-axis and have it translate smoothly into another object's z-axis rotation 1 Answer

Object makes random jumps in rotation 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