Setting up a gear system of sorts...

I really hate being a burden, especially when I don’t know what exactly to do in this case, but I’m not sure what to do here. In brief, what I’m trying to do is alter my control script (which is already a mess of code snippets taken from various online sources) to allow the player to select about 6 speeds (Reverse, Stop, 1/4, 1/2, 3/4, and Full.) while having to only press the button once. (Bridge Commander’s control scheme is a perfect example of this.) So far I’ve managed to program the exact speeds that I want and I’ve successfully bound them to the buttons, but I have no idea how to maintain those speeds when I let go.

     public float xFactor = 70f;
    public float yFactor = 150f;
    public float zFactor = 3f;

    public float AmbientSpeed = 100.0f;

    public float RotationSpeed = 200.0f;

    void Update()
    {
        var x = Input.GetAxis("Horizontal") * Time.deltaTime * xFactor;
        var z = 0.5f;
        var y = Input.GetAxis("Vertical") * Time.deltaTime * yFactor;

        if (Input.GetKey(KeyCode.Keypad0))
            z = Time.deltaTime * 0;
        if (Input.GetKey(KeyCode.Keypad1))
            z = Time.deltaTime * 50;
        if (Input.GetKey(KeyCode.Keypad2))
            z = Time.deltaTime * 100;
        if (Input.GetKey(KeyCode.Keypad3))
            z = Time.deltaTime * 150;
        if (Input.GetKey(KeyCode.Keypad4))
            z = Time.deltaTime * 200;
        if (Input.GetKey(KeyCode.R))
            z = Time.deltaTime * -50;


        transform.Rotate(y, 0, 0);
        transform.Translate(0, 0, z);
        transform.Rotate(0, x, 0);
        Quaternion AddRot = Quaternion.identity;
        float roll = 0;
        float pitch = 0;
        float yaw = 0;
        roll = Input.GetAxis("Roll") * (Time.deltaTime * RotationSpeed);
        pitch = Input.GetAxis("Pitch") * (Time.deltaTime * RotationSpeed);
        yaw = Input.GetAxis("Yaw") * (Time.deltaTime * RotationSpeed);
        AddRot.eulerAngles = new Vector3(-pitch, yaw, -roll);
        GetComponent<Rigidbody>().rotation *= AddRot;
        Vector3 AddPos = Vector3.forward;
    }

Can anybody lend me a hand here?

you dont need to multiply your x or y values by time.deltatime. GetAxis is going to return a value between -1 and 1. -1 being left/down, 0 being no input, and 1 being right/up. Multiplying it by Time.deltaTime (which will be some decimal value like 0.3235235 or something) does nothing at this point other than make control harder. You only need to multiply the very last step by Time.deltaTime, being the actual function to rotate or move the object.

You need to store the selected speed. First off…use “GetKeyUp” or GetKeyDown"…The reason being “GetKey” requires constant pressing for it to be “true”. up or down fires when the button is either up or down. The “Z” value, make it a variable.

public float speed;

Now when the button is pressed, change the speed variable to your desired speed.

         if (Input.GetKeyDown(KeyCode.Keypad4))
             speed = 200;

and finally, where you are actually applying the speed (take note, i didnt multiply by Time.deltaTime in the key press)

   transform.Translate(0, 0, speed * Time.deltaTime);