After importing a file made in Cinema 3D off the web, I discovered that the objects weren't facing in the correct directions. I tried rotating the objects, but the objects' axis's would also rotate. How do I rotate the objects without affecting their axis's? If an attachable script could do it that would be fantastic!
You can either correct this in your 3D modelling app, or correct this in unity. It's generally preferable to correct it in the 3d modelling ap.
In the case of Cinema 4D, I believe you can adjust the pivot by clicking on the icon with the orange arrows on the toolbar that runs down the left side of the screen.
To correct this in unity, the only simple way is to create another empty GameObject, and add your model as a child of that GameObject. You can then adjust the position and direction of your model so that it faces forwards in relation to the empty parent GameObject's orientation. (In unity, the blue arrow shows the forward Z axis).
You could then create a new prefab to contain this parent-child structure, and you would place any movement or control scripts on the empty parent object.
If it is true, this script should work to fix the rotate problem. I am sorry for the writer of the code, but i found it somewhere in the internet, by using copy & paste to my script database. xD
as a pure grafic artist, i am not able to figure out if it is an c-sharp or java script xD but i think it's c-sharp >.<
here it is, i hope it helps:
public Thing : MonoBehaviour {
Quaternion originalRotation;
Vector3 initialFacing;
public void Start() {
// store original rotation quaternion
originalRotation = transform.rotation;
// In what direction does the prefab face?
initialFacing = transform.InverseTransformPoint(Vector3.forward);
}
public void Update() {
Vector3 facing = computeNewFacing();
// compute new rotation
Quaternion newRotation =
originalRotation *
Quaternion.FromToRotation(initialFacing, facing);
transform.rotation = newRotation;
}
}