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 RMihai · Aug 12, 2013 at 09:26 PM · positiongraphicsvalues

Is it possible to assign a quaternion value to the position vector of a object?

i have the following code: var distance : float =6.4;

 function LastUpdate()
 {
   var currentRotation = Quaternion.Euler(0,90,0); 
   transfomr.position -= currentRotation * Vector3.forward * distance;}
 
 
  i want to know how it is possible to assign a Quaternion value multiplied by a Vector 3, multiplied by a float value; i mean what is the result? 


P.S. Sorry for bad english :)

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 nixcs2512 · Aug 12, 2013 at 09:34 PM 0
Share

What you want to do with that code? $$anonymous$$oving a character forward? So i'm sure it won't work, try to use transform.forward(if the script is attached to the character) or player.transform.forward (player is the GameObject that you want to move) ins$$anonymous$$d of Vector3.forward

avatar image DaveA · Aug 12, 2013 at 09:43 PM 0
Share

What are you trying to accomplish, that might help us answer. Quaternion.Euler(0,90,0) should be same general idea as Vector3.up, no? $$anonymous$$aybe that's what you wanted?

avatar image nixcs2512 · Aug 12, 2013 at 10:00 PM 0
Share

sorry for my lack of knowledge about Quaternion,maybe robertu answer is what you need.

And also, why my comment be the answer... I remember exactly that i wrote a comment not answer...

1 Reply

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

Answer by robertbu · Aug 12, 2013 at 09:45 PM

Yep, you can a multiply a Vector3 by a Quaternion to rotate that vector. Note you cannot do it the other way around (multiply a Quaternion by a Vector3). Also note 'transform' is misspelled on line 4 of your code above. I believe your code here is equivalent to:

 transform.position -= Vector3.right * distance;

  • Quaternion(0.0,90.0,0.0) * Vector3.forward - takes the world forward and rotates it 90 degrees, so you end up with World right: (1,0,0);

  • You multiple world right by distance so you end up with a vector (distance,0,0);

  • You subtract that from transform.postion, moving left by 'distance'.

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 RMihai · Aug 22, 2013 at 12:54 PM 0
Share

thak's a lot:)

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

17 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

Related Questions

Shader input position.w, what is it for? 1 Answer

Camera rotation around player while following. 6 Answers

change position and play animation 1 Answer

Unity 3 Animation Positioning Problem 1 Answer

Vector3.Lerp doesn't work! 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