Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed Oct 05, 2017 at 04:10 AM by nocoast for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by nocoast · Nov 04, 2013 at 10:11 PM · transform.rotationtransform.rotatedegreeseuler anglestransform.rotatearound

Transform.RotateAround Issues

alt text

I have attached an image to help explain what is currently happening with my script. I have an equilateral triangle I am trying to rotate around an axis at 120 degree intervals, stopping at each interval until the statement is triggered again (120 degrees because the triangle will rotate into a similar position, with the vertices shifted, from "B" to "C" in the drawing). The triangle is not orthogonally (drawing "A"), so I am using unity's Transform.RotateAround function. I have the script generally working, but I have two questions and one issue.

Q1)The script works when I use 90 degrees, instead of 120 degrees, does anyone know why this is?

Q2)Why do I need to return the rotationAngle variable to zero for the triangle to stop rotating?

I1)The script works for about six iterations, then it becomes noticeable that the triangle is slightly deviating from the original position (drawing "D"). This deviation continues to get worse. I'm hoping this is just an issue caused by Q1 or Q2 and will be fixable after I understand what is happening.

//The following is the code I am currently using inside of the conditional statement

rotationAngle = rotationAngle + 90.0f;

GameObject.transform.RotateAround(rotationAxis,rotationAngle);

rotationAngle = 0.0f;

img001 (2).jpg (305.0 kB)
Comment
Add comment · Show 1
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 robertbu · Nov 10, 2013 at 01:35 PM 0
Share

Try Quaternion.AngleAxis():

 transform.rotation = Quaternion.AngleAxis(rotationAngle, rotationAxis);

AngleAxis() is an absolute rotation. Just increase rotationAngle by 120.

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by zombience · Nov 04, 2013 at 11:21 PM

transform.RotateAround is an additive function. If you put

degree = 5f; transform.RotateAround(axis, degree);

in your update loop, your transform will continue to rotate until you stop playing your scene. it will not move 5 degrees and then stop. you need to manually set that up.

if you want to do something like that, you should look into quaternions, and do something like:

 Vector3 targetRotation = transform.rotation.eulerAngles;
 
 targetRotation.y += 120;
 
 transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(targetRotation), Time.fixedDeltaTime);


this will lerp your rotation into position until it reaches the targetRotation and appear to stop.

Comment
Add comment · Show 2 · 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 nocoast · Nov 10, 2013 at 05:08 AM 0
Share

So I've tried this, and it does not seem to work. I don't need it to Lerp into position, I simply need it to go from B to C instantly.

Thank you for explaining the additive function, that explains Q2) (I have always had a boolean set up to stop this, I just didn't know why I needed it). I am still confused about Q1) and I1) though?

avatar image nocoast · Dec 03, 2013 at 06:52 PM 0
Share

Yesterday, Unity prompted me to use transform.rotate, and that seems to work (I can't remember exactly, but it said something like rota$$anonymous$$round was an outdated function).

Follow this Question

Answers Answers and Comments

16 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

Related Questions

RotateAround object in local space 1 Answer

Rotating game Object. 2 Answers

weird framrate behaviour in day/night cycle 0 Answers

Setting a blocks rotation to predetermined values. 1 Answer

trying to take my door script and apply to a treasure chest 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