• 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 fashrista · Nov 19, 2017 at 04:30 PM · rotationrotation axis

LookRotation or euler angle object rotation towards

I have a project That should draw vectors in 3d space and draw them as actual force in space. Origin is the Vectors default position. I have Vector 3 information about the force, for example new Vector3(213,243,11). I am rescailing vectorGameobject according to vectors magnitude, but am haveing trouble with pointing the vector in right direction, that is the direction of the force. I have tryed this: vectorsLeft[i].transform.localEulerAngles = new Vector3((float)leftCycleAnimationData.Fy[i], (float)leftCycleAnimationData.Fz[i], (float)leftCycleAnimationData.Fx[i]) ; vectorsRight[i].transform.localEulerAngles = new Vector3((float)rightCycleAnimationData.Fy[i], (float)rightCycleAnimationData.Fz[i], (float)rightCycleAnimationData.Fx[i]);

but it draws vectors in exactly oposite direction. Is there a way to revert this direction to -direction? alt text

Then I tryed making a test scene for other rotate functions: alt text

written this code:

 public class RotationController : MonoBehaviour {
 
 
     public GameObject[] cilinders;
     public GameObject tagetObject;
 
     void Start () {
         
     }
     
     public void rotator()
     {
         for (int i = 0; i < cilinders.Length; i++)
         {
             Vector3 target = tagetObject.transform.position;
            
             Vector3 direction = (target - cilinders[i].transform.position) ;
 
             Quaternion rotation = Quaternion.LookRotation(direction/*,Vector3.up*/);
 
             cilinders[i].transform.rotation = rotation;
 
             Debug.Log("direction " + direction.x + "," + direction.y + "," + direction.z + ",");
             Debug.Log("rotation" + rotation.x + "," + rotation.y + "," + rotation.z + "," + rotation.w);
             Debug.Log("cilinders[i].transform.rotation" + cilinders[i].transform.rotation.x + "," + cilinders[i].transform.rotation.y + "," + cilinders[i].transform.rotation.z);
         }
 
     }
 
 }

and got a result:(cannot load more pics): stickc(vectors )seem to be perpendicular to the cube, not pointing to the cube. Any sugestions??

thx

zajeta-slika.png (75.2 kB)
zajeta-slika.png (74.1 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by fashrista · Nov 19, 2017 at 04:31 PM

alt text

ps.: thats the other picture


zajeta-slika.png (66.5 kB)
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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

100 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

Related Questions

Need help with sprite rotation 0 Answers

Limiting X-Axis rotation to 90 degrees and -90 degrees 1 Answer

How can I make player rotation control camera's x rotation and mouse control it's y rotation? 1 Answer

please help to rotate a cube around it's own axis 1 Answer

reverse rotation of game object on button press 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