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 Ariel J · Jul 11, 2010 at 02:18 AM · transformvector3lookatx-axis

How to use x axis for transform.LookAt

I'm using a skinned mesh with bones in it. I've been trying to make one bone's negative x axis look at another transform, but when I use transform.LookAt, it uses the positive z axis.

How can I change this?

Thanks,

Ariel J

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

3 Replies

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

Answer by qJake · Jul 11, 2010 at 02:35 AM

You can't. The "forward vector" of any object is when the Z-axis is pointing at it (just like when you're looking at something, you're facing forward). This behavior cannot be changed.

You're probably going to need to do the math manually to rotate the object how you want it, unless you explain your problem more in-depth (perhaps in another question, since it would probably be unrelated).

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

Answer by CiberX15 · Dec 10, 2017 at 05:58 AM

Sorry, I know this is an old thread but I figured I would offer my solution to this problem. You know LookRotation will return a rotation pointing from the front of the object, so you just need to rotate it 90° on the Y axis to get a Quaternion that looks at your target with the X axis. In code it would look like this:

 Quaternion XLookRotation = Quaternion.LookRotation(dir, transform.up) * Quaternion.Euler(new Vector3(0, 90, 0));

You can of course modify the vector to point any axis or combination of axis towards the target object :)

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

Answer by Anxo · Sep 13, 2010 at 07:40 AM

I have the problem sometimes. What I do is I create an empty game object that is facing in the direction I need it to. Then I make the object that needs to face that way a child of the empty game object and orientated it how I like. Place your code on the Empty Game Object and it will use the Z axis of the empty game object to rotate your object.

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

1 Person is following this question.

avatar image

Related Questions

What is the algorithm to assign to transform.right? 1 Answer

Change a Transform to Aim to the center of a Collider. Not (0,0,0) 2 Answers

Rigidbody to follow player around 1 Answer

Help!!! Transform controls problem for a plan-view air hockey game. 0 Answers

transform.LookAt boundaries 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