Can't get my space ship to go fowards and backwards !

Hi

Struggling with this scrip lark. I’m trying to get my ship to go fowards and backwards (Z Axis). I can get it to go sideways but not up or down can anyone help ???

Many thanks
Matt :smile:

using UnityEngine;
using System.Collections;

public class PlayerMovement : MonoBehaviour {
public float Speed = 10f;
void Update () {
float LeftRightMovement = Input.GetAxis(“Horizontal”) * Speed * Time.deltaTime;
float UpDownMovement = Input.GetAxis(“Vertical”) * Speed * Time.deltaTime;

transform.Translate(LeftRightMovement,0,0);
transform.Translate(UpDownMovement,0,0);
}
}

P.s. Even when i use the up down arrow key, it goes left and right also :slight_smile:

Try either:

transform.Translate(0,UpDownMovement,0);

or:

transform.Translate(0,0,UpDownMovement);

This will make up/down movement either happen on the y or the z axis.

Gibbonator your a star. just got it to work thank you very much.
It was the bottom code that worked :slight_smile: