Ejemplo n.º 1
0
    [HideInInspector] public bool isBraking;                            //The current brake value

    void Update()
    {
        //If the player presses the Escape key and this is a build (not the editor), exit the game
        if (Input.GetButtonDown("Cancel") && !Application.isEditor)
        {
            Application.Quit();
        }

        //If a GameManager exists and not racing...
        if (GameManager.instance != null && GameManager.instance.currentState != GameManager.GameState.Racing)
        {
            //...set all inputs to neutral values and exit this method
            thruster  = rudder = 0f;
            isBraking = false;
            return;
        }

        //Get the values of the thruster, rudder, and brake from the input class

        //thruster
        if (Mathf.Abs(verticalAxisController.GetNormalizedValue()) > Mathf.Abs(Input.GetAxis(verticalAxisName)) && verticalAxisController != null)
        {
            thruster = verticalAxisController.GetNormalizedValue();
        }
        else
        {
            thruster = Input.GetAxis(verticalAxisName);
        }

        //rudder
        float val = horizontalAxisController.GetStepValue(horizontalAxisController.GetValue());

        if (Mathf.Abs(val) > Mathf.Abs(Input.GetAxis(horizontalAxisName)) && horizontalAxisController != null)
        {
            rudder = val;
        }
        else
        {
            rudder = Input.GetAxis(horizontalAxisName);
        }

        //brake
        isBraking = Input.GetButton(brakingKey);
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        controller = GetComponentInChildren <EyeControl>();
        //parts = GetComponentsInParent<TelescopicPart>();
        slider.ValueChanged += OnValueChanged;
        var t = slider.GetNormalizedValue();

        controller.Works(t > 0.9f);
        for (int i = 0; i < parts.Length; i++)
        {
            parts[i].LerpToPos(t);
        }
    }
Ejemplo n.º 3
0
    void Update()
    {
        if (turnControlObject != null)
        {
            turnValue = Mathf.Lerp(-1f, 1f, turnControlObject.GetNormalizedValue());

            if (turnControlObject._grabbed == false)
            {
                if (Mathf.Abs(turnValue) < deadzone)
                {
                    turnValue = 0f;
                }
            }
        }

        if (thrustControlObject != null)
        {
            thrustValue = thrustControlObject.GetNormalizedValue();
        }

        //If a GameManager exists and the game is not active...
        if (GameManager.instance != null && !GameManager.instance.IsActiveGame())
        {
            //...set all inputs to neutral values and exit this method
            thruster  = rudder = 0f;
            isBraking = false;
            return;
        }

        //Get the values of the thruster, rudder, and brake from the input class
        if (inputScheme == InputScheme.VR)
        {
            thruster = thrustValue;
            rudder   = turnValue;
        }
        else
        {
            thruster = Input.GetAxis("Vertical");
            rudder   = Input.GetAxis("Horizontal");
        }

        isBraking = false; //Input.GetButton(brakingKey);
    }