• 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
1
Question by Symons · Apr 01, 2018 at 12:15 PM · rotationtransformvector3quaternions

Rotating a Vector direction by another Vector direction in one axis

Hi, I have been trying to work this one out for a while now and am starting to get Vector poisoning. I have tried many different solutions but to no avail. I am trying to take the product direction of a Vector3.Reflect which I use to make a ball bounce off the floor, but I also want the play to be able to steer when they bounce off the floor, so I have a Vector that is the balls moving position but rotated according to the input by the player. I want to combine these when the ball bounces so that it produces a bounce vector that has been rotated by the players input. Here is a image of what I'm trying to achieve;alt text

When usually getting the turn rotation I just do this Vector3 NewRot = new Vector3 (ParRot.x, ParRot.y += (rot * (BaseRotSpeed*5)), ParRot.z); The ParRot is basically just the current objects rotation. But if I try to combine this with the Bounce vector it affects the vertical speed Vector3 NewRot = new Vector3 (bounceV.x, bounceV.y += (rot * (BaseRotSpeed*5)),bounceV.z); Just getting a normal bounce is like this; private void FloorBounce (float rot, Vector3 bounceV, float forcemulti) { Quaternion BounceDirection = Quaternion.LookRotation (bounceV); Vector3 bouncedir = bounceV * V.magnitude; Parent.transform.rotation = BounceDirection; ThisRB.velocity = new Vector3 (bouncedir.x * 0.95f, bouncedir.y * forcemulti, bouncedir.z * 0.95f); } with bounceV being the Vector3 reflect vector. I have tried doing something like this and got quite close;`bounceV = Quaternion.AngleAxis(ParRot.y += (rot*10), Vector3.up) * bounceV;` or this Quaternion BounceDirection = Quaternion.LookRotation (Quaternion.AngleAxis(NewRot.y - bounceV.y,Vector3.up) * bounceV); But to no avail, please anyone who knows their vectors and Quaternions I could really use your help, thank you!

vectors.jpg (134.1 kB)
Comment
Add comment · Show 1
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 Symons · Apr 02, 2018 at 11:51 AM 0
Share

$$anonymous$$aybe my two vectors are at different orientations, one being from a Reflect and one being a Euler of the objects rotation??

1 Reply

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

Answer by Symons · Apr 02, 2018 at 12:56 PM

Ok realize I could just cheat it like this, so much easier :D

 private void FloorBounce (float rot, Vector3 bounceV, float forcemulti)
     {
         Vector3 newBounceV = Quaternion.AngleAxis(rot*10, Vector3.up) * bounceV;
         Quaternion BounceDirection = Quaternion.LookRotation (newBounceV); 
         Vector3 bouncedir = newBounceV * V.magnitude; 
         Parent.transform.rotation = BounceDirection; 
         ThisRB.velocity = new Vector3 (bouncedir.x * 0.95f, bouncedir.y * forcemulti, bouncedir.z  * 0.95f);
     }
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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

130 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

Related Questions

How can I turn my cube object to the direction it is traveling? 1 Answer

How to get a proper ramming effect? 1 Answer

c# modify only one axis of a quaternion 2 Answers

How to make Y-Axis face away from a position? 2 Answers

Connecting transform with Vector3 4 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