Hi everyone, I need some help!
I have a globe(3ds file) imported and I want to rotate it it:
Here’s the code:
var speed:float = 5;
function Update () {
var horiz:float = Input.GetAxis("Horizontal");
if(horiz > 0)
transform.Rotate(Vector3(0,1,0));
if(horiz < 0)
transform.Rotate(Vector3(0,-1,0));
}
so, the only problem is with the axis! it doesn’t rotate around itself, it rotates around an axis somewhere close to it.
I have the Axis as Local in the scence!
Any suggestions?
The Local/Global button in the Scene view only affects the gizmos in the Scene view, not the objects. If you have problems with flipped axes or bad positioned pivots, the best alternative is to create an empty game object and child your model to it - this way you can move or rotate the model to adjust the pivot position and axes the way you want; the ex-empty object becomes then the main object, to which you will attach components like rigidbody, scripts etc.
EmptyGameObject <- this object will be used to rotate, translate, add components etc.
Model <- the model becomes just a child and can be adjusted the way you want