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 Clw · Jun 30, 2013 at 08:41 AM · rotationinstantiate

Rotating gameObjects gives me completely inaccurate values at runtime

I have my camera at 0,0 , -10 , and I want some gameObjects to be instantiated at even distances between each other around the screen, in the shape of a circle. This works. But when I want all of them to rotate, to point at the middle of the screen, they get weird values and none of them are correct. For example, one building has the rotation x :353, y: 153, z: 153, another one has x: 331, y: 126, z: 126. Can you help me out, I would go on and focus on something else but I like finishing stuff in advance before doing other stuff. I want the Y and Z to be at 90 degrees, and just X to change depending on the building itself.

 for(int i=1; i<=buildingButtonAt.Length ; i++){
         Vector3 location = new Vector3(
             Mathf.Sin (((2*Mathf.PI)/buildingButtonAt.Length)*i)*8,
             Mathf.Cos (((2*Mathf.PI)/buildingButtonAt.Length)*i)*8,
             9);
         Quaternion rotation = new Quaternion(
             (Mathf.Rad2Deg)* (((2*Mathf.PI)/buildingButtonAt.Length)*i),
             90.0f,
             90.0f,
             0.0f);
         
         buildingButtonAt[i-1] = (GameObject)Instantiate (Resources.Load ("Building"),location,rotation);
  }


Comment
Add comment · Show 3
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 Benproductions1 · Jun 30, 2013 at 10:14 AM 0
Share

It's hard to understand what you want to achieve. Please be more specific and detailed :)

avatar image Clw · Jun 30, 2013 at 11:10 AM 0
Share

I've been trying to do something like this http://imgur.com/orBSSzp . I'm referring to the gameObjects that have the black arrow on green transparent material. This has been done by manually arranging them, because they go into wacky directions. I have managed to make it 1 $$anonymous$$ute ago, repsonding on the answer section

avatar image Benproductions1 · Jun 30, 2013 at 11:48 AM 0
Share

Are you sure you understand how Quaternions work. It seems you are trying to construct one using degrees... that does not work. use Quaternion.Euler if you want to get the quaternion equivalent of Euler rotation :)

1 Reply

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

Answer by Clw · Jun 30, 2013 at 12:08 PM

I've set the default rotation on instancing the game object to (0,0,0,0), and used the Rotate method like so to achieve the rotation :

 buildingButtonAt[i-1].transform.Rotate (
             360 -(Mathf.Rad2Deg)* ((2*Mathf.PI)/buildingButtonAt.Length)*i,
             90,
             90);
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

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

Instantiate an image, equally in a circle and rotate it away from the center? 2 Answers

Create plane from 2 Vectors of a symmetry line segment 1 Answer

Specify rotation of instantiated object 2 Answers

Rotation Problem 1 Answer

What would cause an objects transform to be different from its onscreen position? 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