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
1
Question by Quantum · Apr 25, 2011 at 11:18 AM · gameobjectaxischangecustomizexyz

Changing the gameobject xyz-axis

Hi,

is it possible to change the xyz-axis of a gameobject?

Say by instance there is a gameobject with the z-axis facing backwards, and you want the z-axis to face forward. Because maybe you would like to create a script with a LookAt() function so it's facing the right direction.

I know you can parent the gameobject in an empty gameobject with the correct orientation. BUT, this adds another problem. That is, whenever you want to destroy the gameobject while colliding with something else, it only destroys the colliding gameobject (and not the empty gameobject, because you don't want to add a collider to the empty gameobject for several reasons). And yeah, I know there are several other solutions to solve these problems (adding tags etc.), but this is really a time-consuming method. Especially when you have lot's of different gameobject that has to do the same thing.

So it would be a lot easier if there was a way to change the xyz-axis in an orientation with respect to the gameobject without adding the gameobject into an empty gameobject.

Is there any way to do this?

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 Alec-Slayden · Apr 25, 2011 at 12:14 PM 0
Share

As a comment on your empty game object; you can always access the transform.parent, and destroy that. It's maybe another 1 or 2 lines of code tops. Corrective nesting is probably going to be your easiest option, if you can't re-save the asset with a corrected axis.

3 Replies

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

Answer by Eric5h5 · Apr 25, 2011 at 11:35 AM

No, not really. You should always just create your objects so the z-axis faces forward in the first place, saves lots of headaches.

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 Scribe · Apr 25, 2011 at 02:08 PM 0
Share

I love the simplicity of your answers :)

avatar image smoggach · Sep 26, 2014 at 07:37 PM 0
Share

Unity could save us all a lot of pain by starting 2D projects with an orthographic camera looking down ins$$anonymous$$d of forward.

avatar image
12

Answer by Joshua · Apr 25, 2011 at 12:12 PM

Instead of changing it it is much easier to just have an empty GameObject.

First: Child this empty gameobject to your original gameobject Then: Reset the transform of your empty gameobject so it centers. Then: Un-child the empty gameobject Then: Rotate the empty gameobject to face the way you want Then: Child the original gameobject to the empty gameobject.

Now you can use this empty gameobject as the original gameobject with the axes fixed.

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 fscopel · Jan 07, 2016 at 11:03 PM 0
Share

This is perfect! Thank you for posting the tip!

avatar image Bhanuteja_g · Sep 03, 2020 at 02:34 AM 0
Share

Thanks. This was very helpful.

avatar image
0

Answer by Jean-Fabre · Apr 25, 2011 at 11:35 AM

Hi,

The only alternative given your requirements is to rotate the mesh vertices themselves, that is: Iterate each vertices of your mesh, and rotate them. In Max, this is actually how it's done internally when you affect the pivot.

I just can't find the script that did that, I am sure someone already build an editor or even run time tool for that, but just can't find it, will edit when I will :)

Bye,

Jean

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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How Do I Change The Transform Data For Each Object? 1 Answer

Want to be able to change color of individual cubes by clicking 2 Answers

How to code anywhere below -10? 1 Answer

script help gameobject to playercar 1 Answer

Change bool in only one GameObject 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