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 MasterLetch · Apr 24, 2012 at 07:28 PM · rotationquaterniondirectionvector

Creating Hint Vector

long story short, I need to create a function like transform.LookAt or Quaternion.LookDirection that doesn't use Vector.forward as the direction or to find a way to create a hint vector in a function like Quaternion.FromToRotation.

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 MasterLetch · Apr 24, 2012 at 10:48 PM 0
Share

I am more then aware of the two vectors needed in those function, that is indeed why i want to change the axis it is operating on. and as true as it is that you can assign them... its not much more then a rotation, which in this perticular case doesn't help. tho I realize there are many different ways of attack this current problem. if I had a function like Quaternion.AngleAxis that set a group of local rotations... i would also be fine...

avatar image Bunny83 · Apr 25, 2012 at 03:29 AM 0
Share

So do you want to just do a relative rotation? Something like: You have a local arbitrary direction vector which should point into a certain direction. So you want to rotate the object that this vector (which is fix in local space) should point into / to a certain world space direction / point? If so, why not just using Quaternion.FromToRotation like you've mentioned? It calculates a rotation which rotates a given vector, so it points into the direction of "toDirection"

Example:

 Vector3 localVector = (new Vector3(0,1,1)).normalized; // forward but 45° up
 transform.rotation = Quaternion.FromToRotation(localVector,targetDirection);

I've tested it and it works like you would expect. Of course without a second vector the rotation around the direction vector might look a bit strange, but a single vector doesn't define a whole coordinate system.

avatar image MasterLetch · Apr 25, 2012 at 12:17 PM 0
Share

without an up vector defined, my ship takes routes that aren't helpful, tho I realized my problem was actually converting a world rotation to a local rotation... and LookRotation was working very well.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Apr 24, 2012 at 07:44 PM

Well, the calculations behind lookat aren't that complicated, but are you aware of that you need two vectors? LookAt takes one direction and one up-vector and aligns the z-axis with the direction and the y-axis "in the direction of" the given up-vector.

As far as i know you can simply assign a vector to transform.up to make the upvector point into that direction, but i never used this.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Rotating a direction Vector3 by Quaternion 2 Answers

How do I rotate an object to face a direction. 1 Answer

Unity thinks my Quaternion is a Float 2 Answers

Object not rotating when the associated trigger is triggered 1 Answer

Rotate vector3 relative to another vector3 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