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 /
avatar image
0
Question by Lemo76 · Dec 20, 2014 at 09:02 AM · rotationeditorfloatsnap

Rotation Snapping is adding harmful floats!

Here's the story,

So my game is set up so that there are tiled platforms set up into a sphere.

Each tile is 4 degrees apart.

Here's a reference image:

alt text

Ok, so in this game there are quite a lot of tiles (around 100) per level.
I used the rotation snapping tool to place the tiles quickly.
What was going on is the coordinates had this long float added
(e.g. 187.999999 when it should just be 188).

That wasn't exactly a problem, until later when whole numbers where added on top which actually affected and shifted the tile slightly off center
(e.g. 1.47855434232 when it should just be 0).

As I went to later platforms, the numbers got really messy.
alt text

I would usually ignore it if it is just something like 3.99999, but when I go forth and duplicate and rotate that it procedurally gets more different to what it actually should be.
As you could assume it would be really annoying going to each platform and setting them back to their "degree of 4".

Are there any such ways I can get by this? e.g. simple fixes/external tools

Thanks for all the help, I hope I've explained myself.

1.png (134.9 kB)
1.png (11.2 kB)
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
0
Best Answer

Answer by Lemo76 · Dec 21, 2014 at 11:04 PM

Figured it out:

All I required was this simple script (the world was only rotating on the x and z axis):

 var Degree : float = 4;
 
 function Start () {
 transform.localRotation.eulerAngles.y = 0;
 transform.localRotation.eulerAngles.z = (Mathf.Round(transform.localRotation.eulerAngles.z/4)*4);
 transform.localRotation.eulerAngles.x = (Mathf.Round(transform.localRotation.eulerAngles.x/4)*4);
 }

This snaps the platforms to the nearest factor of 4.

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

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

26 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

Related Questions

Multiple Cars not working 1 Answer

Editor Button Rotates Selected Object 1 Answer

Looking for ideas of how to control specific values from C# 1 Answer

Object problem 1 Answer

Lock the Camera's Y Rotation Axis? 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