|
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 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?
(comments are locked)
|
|
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
(comments are locked)
|
|
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.
(comments are locked)
|

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.