• 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 midomido · Jul 26, 2012 at 06:30 PM · rotationaxislookatlimitz

LookAt Limit Up and Down rotation only

i have 2 cubes in my one is static that looks at the other object so when i move the other object the first cube should rotate it self to the other one but the problem is i want it to do this only in the Z axis or up and down only = 1 axis , but when ever it start looking the x,y,z all change while i want them all to remain 0 except the one that looks up and down at the other cube i tried something to limit the Y and it worked but it doesnt work with Z , any help ?

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 Piflik · Jul 26, 2012 at 06:52 PM 0
Share

Please at least try to use complete sentences with proper grammar and punctuation. It is really hard to figure out what your talking about.

Also it would help if you provided some information, most notably the script you use for rotating the cube.

2 Replies

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

Answer by midomido · Jul 27, 2012 at 11:17 PM

never mind , my problem was that when my 1st cube starts to LookAt(Cube2) all the axis start to change (X,Y,Z) all i wanted is the Z axis only , i fixed this using

var relativePos = Vector3 Cube2.position - Cube1.position; var rotation = Quaternion.LookRotation(relativePos); Cube1.rotation = rotation;

thanks for your help though

Comment
Add comment · Show 1 · 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 IndieScapeGames · Jul 28, 2012 at 02:20 AM 0
Share
  • for sharing your answer.

avatar image
1

Answer by IndieScapeGames · Jul 26, 2012 at 07:24 PM

Please post some code and we'll be able to help better. We don't even know what language you are using.

I would say that use the same logic as what is working for the Y axis, but in the parameters 0 out the Y information, and put the information in the Z's place.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

How can I rotate towards/look at a specific axis of a collided object? 2 Answers

Object facing the wrong way? 1 Answer

limiting rotation to solid angle 5 Answers

LookAt() with X axis 1 Answer

[Please!] Noob need's help with planet gravity movement. 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