How to change the "front" of my object?

Now I feel like this is a stupid question (i’m trying to learn javascript), but it’s really stumped me, so here goes! When I import in a model, I can then rotate it however I like, but the script doesn’t treat the visual front (it’s a starship) as the front, instead it propels it sideways. Yet rotating it left and right works…

This is the code i’m dissecting:

var life:int;

var thrust:int;



var rotationSpeed:float;

function Update(){

var h=Input.GetAxis("Horizontal");

var v=Input.GetButton("Vertical");

transform.Rotate(Vector3(0,h*Time.deltaTime*rotationSpeed,0));

if(v){

rigidbody.AddForce(transform.forward*Time.deltaTime*thrust);

}

}

Does this have something to do with local or world space? How is the “front”/“sides” of an object set, and how can I change them? I’d appreciate any help you guys can give! Thanks!!!

This issue plagues new users.

Try like this:

  • create a new empty gameobject
  • put your script on this empty gameobject
  • drag the model as a child of the empty gameobject, and orient it as it should, with its front following the world z axis (the blue axis)

All rotations that you apply to the parent will propagate to the child, regardless of its weird original rotations (that are ‘normally awkward’ on imported models)