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?

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.

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

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