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 aarontrotter · May 28, 2019 at 09:32 PM · vector3scale

Scale objects of different rotations by a single direction

 i am struggling with vector math.
 I have two objects that have been rotated in the world yet I want to scale in the same direction relative to a specific direction and not to their own forward direction.
 
 I have two cubes
 [box1]
 rotation = 0, 0, 0
 scale = 1, 1, 1
 directionToWorld = 1, 0, 0
 
 [box2]
 rotation = 0, 90, 0
 scale = 1, 1, 1
 directionToWorld = 0, 0, 1
 
 No matter their rotation, I want to scale them in the same direction relative to the world.
 [world]
 direction = 1, 0, 0
 
 lets say i want to multiply their scale based on a new vector of 2,1,1 using the worlds direction.
 
 I want to retrieve the following
 [box1]
 scale = 2, 1, 1
 [box2]
 scale = 1, 1, 2
 
 Can anyone give me an idea how to do this. Thank you.


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
Best Answer

Answer by Epsilon_Delta · May 29, 2019 at 09:53 PM

You might have oversimplified your example to the level I am not sure what you want to achieve. If you really want only to rotate your objects by 90 degrees, you can devise a system that swaps the scaling eg. around y by 90 degrees swaps the x and z scaling and so on. With some additional thinking and linear algebra, it is maybe even possible to devise a one-liner function that swaps this automagically.

However if you want to rotate your objects by any other angle (like 45 degrees) , this is not possible. You can only scale your transform in three perpendicular axes. Even if you try to somehow project the world coordinate scaling vector to the gameobject transform coordinate system, the outcome would be different. If you scale square in x axis and then in y axis you get rectangle, if you scale it diagonally, you get rhombus.

That being said, the best solution for not-rightangle-rotations-case in my opinion is this: Make your gameobjects child of empty gameobject (transform) (every gameobject can have individual parent, or they can be children of the the same one - depends what you want). Rotate only your child gameobjects and keep their parent transform at (0,0,0) rotation. Then scale their parent.

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 aarontrotter · Jun 05, 2019 at 07:34 PM 0
Share

Scaling the parent sorts the problem.

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

135 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

Related Questions

Scale and position object between two points 1 Answer

Object Scale Lerp with rigidbody addforce jump duration. 1 Answer

I'm trying to make a zoom by changing the scale of the object and need constraints 1 Answer

Vector3.Scale and rotated colliders 1 Answer

How can i keep global scale of object while instantiate it 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