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 moosefetcher · Jan 07, 2016 at 05:15 PM · rotationtransformrotatearound

Error with transform.RotateAround when I use a variable for the last parameter...

Hi there! Another day, another seemingly strange and unsolvable problem...

I'm setting up the rotations for the planets in a space exploration game. I've got the planets rotated to various inclinations and I've got them rotating around their local 'up' axes. But....

Each planet has a _rotationAdjustment float which represents the amount of degrees the planet should rotate per second. I'm using:

 transform.RotateAround( Vector3.zero, _rotationAxis, _rotationAdjustment * Time.deltaTime );

...which works fine, but when I test the game it's throwing the following error:

 transform.position assign attempt for '' is not valid. Input position is { NaN, NaN, NaN }.
 UnityEngine.Transform:RotateAround(Vector3, Vector3, Single)

Which seems to do nothing but slow the game down, which is annoying. When I replace the _rotationAdjustment variable with a literal value, say -0.02, I don't get the error. I have Debug.Log-ed _rotationAdjustment at various places, and it always displays as a valid value (NOT NaN or infinity, for example).

Oddly, the error message gives the third parameter as a 'single', but Unity didn't recognise that type when I tried (single)_rotationAdjustment.

Any idea what's happening here? And if not, is there a different transform method I can use to rotate around an axis?

Cheers.

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 Owen-Reynolds · Jan 07, 2016 at 07:52 PM 0
Share

I can't duplicate it, but: notice how it's angry about the new position being illegal, so I think you're on the right track -- you're computing using impossible values. Is _rotationAxis ever all 0's (which should be an error, but my Unity5.2.1 simply does nothing.)

I believe Single is just another word for float. Error messages don't always use consistent terms.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by taylank · Jan 07, 2016 at 09:00 PM

Can't think why you're having that error, but here is a link to how to do RotateAround without using the transform function: http://answers.unity3d.com/questions/489350/rotatearound-without-transform.html

The C# version of the code is in the comments area.

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 Owen-Reynolds · Jan 07, 2016 at 09:49 PM 0
Share

From the OP's 3rd-from-the-bottom Para: " I have Debug.Log-ed _rotationAdjustment at various places, and it always displays as a valid value (NOT NaN or infinity, for example)."

We try to move Qs from users that need basic help into the HelpRoom area. I left this Q in main UA since it seems like it might be a real-ish problem.

avatar image taylank Owen-Reynolds · Jan 07, 2016 at 10:44 PM 0
Share

I've missed that, my bad.

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

36 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 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 avatar image avatar image avatar image avatar image

Related Questions

Resetting transform's original position and rotation after using transform.rotateAround 1 Answer

Ball Rolling Animation Not Working Properly 0 Answers

Orbit around orbiting object (transform.RotateAround) 1 Answer

How to rotate an object around a screen point (mousePosition)? 1 Answer

RotateAround Limitations 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