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 spendew · Jul 22, 2012 at 05:50 PM · rotationdirectionaxislookface

Make object face direction only on one axis

So I have an object that can be placed on another object, the problem is that when the object is placed on another surface with a different rotation the "up" rotation of the object changes.

Its easier to explain in pictures:

Lets say the part of the tire that says "Big Wheel" is the top of the object alt text

When that object is moved to the other side of the engine (big white object) the wheel rotates so that "BigWheel" is now facing the side: alt text

I do not want the wheel to rotate like that, I want it to always be facing the same way on one axis.

Please note that in this part of my game the player is creating a vehicle and the wheels need to be facing the ground so that the WheelColliders work when the player runs the simulation. Also the wheel consists of two objects (the wheel and the "axel" which the wheel is parented to).

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 Owen-Reynolds · Jul 22, 2012 at 07:22 PM 0
Share

What sort of code are you using to orient them?

$$anonymous$$y 1st try would be to assume you have empties as placement mountPoints, and use tire.rotation = placeTarget[i].rotation;.

But that would make it work the way you want, so you must have some other set-up, where the obvious way won't work.

avatar image spendew · Jul 23, 2012 at 06:36 PM 0
Share

They are just parented to the axel, with no other code to change their direction.

avatar image Owen-Reynolds · Jul 24, 2012 at 05:24 AM 0
Share

It seems like the evidence says there is code, somewhere, to change the direction.

Just rechilding: wheel.parent=axel2; doesn't change position or rotation (but might change it later, as the parent moves/spins.)

1 Reply

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

Answer by ScroodgeM · Jul 23, 2012 at 06:46 PM

don't use euler angles (rotation XYZ in inspector) to store "up" rotation. euler angles is just a representation of Quaternion (rotation is stored in this format). not unique. so two different rotations in euler angles can be the same.

so first create a default rotation (where wheel is UP (strange sounds)) and then use transform.RotateAround(...) method to rotate around Y axis. so you can be sure wheel always be UP

for example (imagine or try that) when you rotate an object in euler angles by 90 or 270 degrees around X axis, your Y and Z rotations are rotates object around the same axis...

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

C Sharp Rotate 2 Answers

Control object yaw by two axis 1 Answer

Rotate object so a specific axis faces another object, while also relative to the parent direction 1 Answer

2D Rotate object so y axis faces other object 1 Answer

rotation LookAt of 2D gameObject in 3D space 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