Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
  • Help Room /
This question was closed Apr 23, 2021 at 09:59 AM by ComeSweetDeath for the following reason:

Other

avatar image
0
Question by ComeSweetDeath · Apr 21, 2021 at 04:47 AM · lookrotation

LookRotation() * Vector to rotate a vector?

Context: I'm having trouble using LookRotation() to find the same result as transform.right. The following code draws 3 gizmos (forward, right, and up) in the local space of a cube, and I'm trying to accomplish this using a convoluted method, which is to apply a LookRotation() Quaternion-rotation on Vector3.right and Vector3.up, to find their local space equivalent.

However, only the conversion of Vector3.forward has been successful.

Can anyone help me understand why this is not working? Greatly appreciated.

alt text

 using UnityEngine;
 
 public class DirectionalOffsetTests : MonoBehaviour
 {
     Vector3 myPos => transform.position;
 
     private void OnDrawGizmosSelected()
     {
         Vector3 fwd = transform.forward;
 
         //These are perfectly right
         Debug.DrawRay(myPos, transform.forward, Color.blue);
         Debug.DrawRay(myPos, transform.right, Color.red);
         Debug.DrawRay(myPos, transform.up, Color.green);
 
         Vector3 up = Quaternion.Euler(0f, 0f, 90f) * fwd.normalized;
 
         Vector3 localForward = Quaternion.LookRotation(fwd, up) * Vector3.forward;
         Vector3 localRight = Quaternion.LookRotation(fwd, up) * Vector3.right;
         Vector3 localUp = Quaternion.LookRotation(fwd, up) * Vector3.up;
 
         Gizmos.color = Color.blue;
         Gizmos.DrawSphere(myPos + localForward, 0.2f);
         Gizmos.color = Color.red;
         Gizmos.DrawSphere(myPos + localRight, 0.2f);
         Gizmos.color = Color.green;
         Gizmos.DrawSphere(myPos + localUp, 0.2f);
     }
 }


q.png (19.3 kB)
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

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

157 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 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 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 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 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 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 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 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 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 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

LookRotation with constant speed 0 Answers

Why does RotateTowards rotate in an "orbit" rather than on the spot? Help me understand! 0 Answers

instantiate a decal for broken glass 0 Answers

Combining Rotation = and Rotate() 1 Answer

How are angles measured in unity. Is it the mathematical way or the compass bearing way? 0 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