コード例 #1
0
ファイル: MouseLook.cs プロジェクト: atikana/Game-Jam-1
    // Update is called once per frame
    void Update()
    {
        if (!levelManagement.isGameOver())
        {
            float mouseX = Input.GetAxis("Mouse X") * sensitivity * Time.deltaTime;
            float mouseY = Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
            xRotation -= mouseY;
            xRotation  = Mathf.Clamp(xRotation, -90f, 90f);

            transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
            playerBody.Rotate(Vector3.up * mouseX);
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (!levelManagement.isGameOver())
        {
            if (controller.isGrounded && velocity.y < 0)
            {
                velocity.y = -2f;
            }

            float x = Input.GetAxis("Horizontal");
            float z = Input.GetAxis("Vertical");

            Vector3 move = transform.right * x + transform.forward * z;

            controller.Move(move * speed * Time.deltaTime);

            velocity.y += g * Time.deltaTime;
            controller.Move(velocity * Time.deltaTime);
        }
    }