Moving in World Space vs. Local Space

So I’m working on a game where you’re in space with a jetpack, and I’m having problems with the movement. I want to be able to have him move forward and continue in that direction regardless of which way he is facing, but when you move forward again, he moves forward in his own local space, but to continue moving that direction in world space. I can either get him to move in local space, and stay moving in local space, or get him to move in world space, and stay moving in world space. I want to know how to do both simultaniously.

var speed = 1.0;
var acceleration = 0.5;
var x = 0.0;
var y = 0.0;
var z = 0.0;

function Update () {

	var forward = Input.GetAxis("Vertical") * Time.deltaTime * speed;
	var sideways = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
	
	if(forward>0) {
		z = z+acceleration; }
		else if (forward<0){
		z = z-acceleration; }
	if(sideways>0) {
		x = x+acceleration; }
		else if (sideways<0) {
		x = x-acceleration; }	
	
	transform.Translate(x,y,z,Space.World);

}

I’m still new to much of Unity and it’s coding, so any help would be appreciated. Thanks! :grin:

Have the jetpack character parented to another object. Now make this new object move forwards and have the player controls on the jetpack character affect the local position.
Hope this helps.

Transform.translate for

I get what you’re saying, but how exactly will that work? Make the parent object the one that actually moves, and have the jetpack guy propel it forwards?

Store his velocity in world space, and use the character’s transform.forward (and/or up and/or right) when figuring out what to add to the world-space velocity.