コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        // try to go left if possible
        if (Input.GetKeyDown(KeyCode.A) && !transitioning)
        {
            if (currentLane.HasLeftLane())
            {
                transitioning = true;
                currentLane   = currentLane.GetLeftLane();
                StartCoroutine(ChangeLane());
            }
            else
            {
                Debug.Log("No left lane!");
            }
        }
        // try to go right if possible
        else if (Input.GetKeyDown(KeyCode.D) && !transitioning)
        {
            if (currentLane.HasRightLane())
            {
                transitioning = true;
                currentLane   = currentLane.GetRightLane();
                StartCoroutine(ChangeLane());
            }
            else
            {
                Debug.Log("No right lane!");
            }
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }
    }