How can I reorient the axes of an object?

How can I reorient the axes of an object?

I spent some time in Unity yesterday trying to fire a sphere from a horizontal cylinder (like a ball from a cannon). I was using Vector3.forward, but the sphere kept coming out the top of the cylinder rather than the front. Someone suggested using Vector3.up instead, and sure enough it worked!
The cylinder is vertical by default. So, it appears that when I rotated the cylinder by 90 degrees to lay it flat, the local axes remained the same. The relative front of the cylinder remained at the same point, so when I fired the sphere it shot out the new "top", not what looked to me like the "front". If I had happened to be facing the other way, I would have had to fire at Vector3.down instead.
How can I reorient/reset the axes of an object so that they match my expectations? (And if I can't, how can I tell by looking which way an object is oriented?)


Answer 1:

Click on the object in the scene, and look at the Rotation values in the Inspector. This will tell you which way the object is oriented in absolute terms.

If the orientation does not match your expected axis (for example, 90 degrees off, or using an unintuitive axis for a given direction), you cannot change the axis of the object itself. Instead, you can use a “parent transform” as follows:

Create an empty GameObject as a parent of your object, and align its transform with your model’s expected axis. Now use the parent transform to reference and manipulate the child object.

Answer 2:

Try using transform.up and transform.right instead of Vector3. Vector3 takes the world coordinates and transform.up takes into account the transform’s orientation.

Answer 3:

But if your model don’t be modeled to get the axis z to front in the modeller program you can’t arrange this in unity