Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        animator.SetBool("isRunning", false);

        if (Input.GetKey(KeyCode.UpArrow))
        {
            animator.SetBool("isRunning", true);

            character.transform.Translate(
                new Vector3(
                    transform.forward.x * 0.05f,
                    transform.forward.y * 0.05f,
                    transform.forward.z * 0.05f), Space.World);
        }
        if (Input.GetKey(KeyCode.DownArrow))
        {
            animator.SetBool("isRunning", true);
            character.transform.Translate(
                new Vector3(
                    transform.forward.x * -0.03f,
                    transform.forward.y * -0.03f,
                    transform.forward.z * -0.03f), Space.World);
            character.transform.rotation = lookInDirection("Backward");
        }
        if (Input.GetKey(KeyCode.RightArrow))
        {
            animator.SetBool("isRunning", true);
            character.transform.rotation = lookInDirection("Right");
            character.transform.Translate(
                new Vector3(
                    transform.forward.x * 0.01f,
                    transform.forward.y * 0.01f,
                    transform.forward.z * 0.01f), Space.World);
        }
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            animator.SetBool("isRunning", true);
            character.transform.rotation = lookInDirection("Left");
            character.transform.Translate(
                new Vector3(
                    transform.forward.x * 0.01f,
                    transform.forward.y * 0.01f,
                    transform.forward.z * 0.01f), Space.World);
        }
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            PauseScript.togglePauseScreen();
        }
    }