Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 MinorMapillai · Feb 07, 2019 at 05:04 AM · rotationmovementcuberelativerelative rotation

Rotate an object such that it is theta degrees relative to another object

I have two cubes where one is static and another moves freely.
The point of the program is to move a cube by a random increment (for the X and Z coordinates) till they reach the ideal distance and ideal angle (10 units and 45 degrees) and they're supposed to move and rotate only along the XZ Axis (The camera is orthographic pointing downwards along the Y axis).
Right now I have the moving part of it figured out and working perfectly.
The only thing I have a problem with is the rotating part.
I tried moving the cube relatively to the static cube but when I do that, the moving cube pivots around the static cube instead of rotating in its place to an angle such that it makes a 45 degree angle with the static cube. I did the above using: transform.RotateAround(staticCube.transform.position, Vector3.up, 45); and it does not work.
Any ideas on how I can do this?

Comment
Add comment · Show 4
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 $$anonymous$$ · Feb 07, 2019 at 05:42 AM 1
Share

Is there any chance you can post a picture or video of what you're trying to achieve? It's kind of hard to understand what you're explaining without a visual image.

avatar image xxmariofer · Feb 07, 2019 at 08:48 AM 0
Share

hello, you want the object to rotate arround the object or to rotate in place?

avatar image MinorMapillai xxmariofer · Feb 11, 2019 at 09:41 PM 0
Share

@xxmariofer It has to rotate in place such that the angle between the two cubes is 45 degrees

avatar image xxmariofer MinorMapillai · Feb 11, 2019 at 09:59 PM 0
Share

you mean something like the object rotationof object a is (0,0,0) and object be (0,45,0)?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Captain_Pineapple · Feb 07, 2019 at 12:10 PM

Hey there,

just a wild guess but this should solve your issue:

transform.RotateAround(transform.position, Vector3.up, 45);

RotateArounds first argument is the position that you will use as pivot. So easier would probably be to use transform.Rotate() here since it defaults to transform.position as pivot point. (Not tested but i think it's this way. Let me know if that was wrong :))

Comment
Add comment · Show 2 · 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 MinorMapillai · Feb 11, 2019 at 09:40 PM 0
Share

That's what I am doing now and it doesn't seem to work the way I need it to.

avatar image Captain_Pineapple MinorMapillai · Feb 13, 2019 at 07:15 PM 0
Share

But the code you provided is not the same as the one i posted in my answer. Did you test my solution?

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

178 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Global movement 0 Answers

Camera Relative Movement 2 Answers

Setting z value of trans.pos relative to rotation 1 Answer

2d Movement Messes up when cube is rotatated 0 Answers

How do I check a rotation relative to another object's rotation? 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