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!!!