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 Danimita92 · Sep 23, 2012 at 06:38 PM · rotationtransformquaternion

Player forward in Kinect

Hi everyone!

Here's my problem. I suck at rotations, so I don't really know how I would rotate this. The thing is, I have three objects. One in the middle, the others on the sides. The ones on the sides move freely, but never rotate. They always look forward. The central object should rotate depending on how the others move. It should rotate so that it always has the other objects at its sides.

"Ok, yes, I also have a point for the head that I could use"

Thanks for reading! I hope you can help me!

Comment
Add comment · Show 2
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 aldonaletto · Sep 23, 2012 at 06:50 PM 1
Share

Not clear! How should the middle object align to the others? Please post a drawing - even the most awful one is worth a thousand words!

avatar image Danimita92 · Sep 23, 2012 at 07:04 PM 0
Share

It would be something like this: http://desmond.imageshack.us/Himg528/scaled.php?server=528&filename=rotation.png&res=landing

How could I make the $$anonymous$$pot rotate like that if I only have the positions of the balls?

1 Reply

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

Answer by whydoidoit · Sep 23, 2012 at 07:30 PM

Ok I haven't tried this but I think that it's right! The position in the centre of the line is calculated by:

  var ball1Position = ball1.transform.position;
  var ball2Position = ball2.transform.position;
  var connectingLine = (ball2Position - ball1Position);
  var centrePoint = ball1Position + (connectingLine * 0.5f);
 

Given that you now need to decide which way to point the centre object- this needs another vector to describe what would be up.

  var upVector = Vector3.up; //Or use something else (like the head per @fattie)

Now rotate the line 90 degrees around that axis for the rotation of the object.

  yourObject.rotation = Quaternion.LookRotation(Quaternion.AngleAxis(90, upVector) * connectingLine, upVector);
  yourObject.position = centrePoint;

 
Comment
Add comment · Show 9 · 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 Danimita92 · Sep 23, 2012 at 08:16 PM 0
Share

Hey there! $$anonymous$$aybe if I clarify what I'm trying to do, it'll help you understand what I need: I'm working on a $$anonymous$$inect project that's giving me certain "nodes". The one's I'm interested in are HIP_CENTER, HIP_LEFT and HIP_RIGHT that move around 3d space but don't rotate. So what I'm trying to do is rotate the hip's center so that it's left side is looking at HIP_LEFT and it's right side is looking at HIP_RIGHT. So if the player turns round, so does the hip's center. And if the player tilts his body left or right, the hip rotates too.

avatar image whydoidoit · Sep 23, 2012 at 08:30 PM 0
Share

So you know where HIP_CENTER is?

avatar image whydoidoit · Sep 23, 2012 at 08:31 PM 0
Share

Because then your upVector is Vector3.Cross(ball1Position - hipCenterPosition, ball2Position - hipCenterPosition) - presu$$anonymous$$g that it is not expressly on the line between ball1 and ball2.

avatar image Danimita92 · Sep 23, 2012 at 08:31 PM 0
Share

It should be in the exact center between HIP_LEFT and HIP_RIGHT

avatar image Danimita92 · Sep 23, 2012 at 09:59 PM 0
Share

Ok so I have these variables:

public Transform left; //Left hip

public Transform right; //Right hip

public Transform up; //Head

and this code:

Vector3 leftPosition = left.transform.position;

Vector3 rightPosition = right.transform.position;

Vector3 connectingLine = (rightPosition - leftPosition);

Vector3 centrePoint = leftPosition + (connectingLine * 0.5f);

Vector3 upVector = up.position - centrePoint;

transform.rotation = Quaternion.LookRotation(Quaternion.AngleAxis(90, upVector) * connectingLine, upVector);

But it spins around like crazy.

Show more comments

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

12 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

Related Questions

player rotation to follow the mouse 2 Answers

Instantiate GameObject towards player 0 Answers

Transform a Vector by a Quaternion 1 Answer

Object not rotating when the associated trigger is triggered 1 Answer

Unity Quaternion Problem (Should be A Bug?) 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