예제 #1
0
    void FixedUpdate()
    {
        yaw   = speedH * Input.GetAxis("Mouse X");
        pitch = speedV * -Input.GetAxis("Mouse Y");
        roll  = transform.eulerAngles.z;

        if (Input.GetButton("Left"))
        {
            roll += rollSpeed * Time.deltaTime;
        }
        if (Input.GetButton("Right"))
        {
            roll -= rollSpeed * Time.deltaTime;
        }

        transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, roll);
        transform.Rotate(pitch, yaw, 0f);

        forward = transform.forward;

        if (Input.GetButton("Jump"))
        {
            rb.velocity += forward * movementStrength * Time.deltaTime;
            playerAudio.IncreasePitch();
        }
        else
        {
            playerAudio.DecreasePitch();
        }
        rb.velocity = forward.normalized * rb.velocity.magnitude;

        currentSpeed = rb.velocity.magnitude;

        if (rb.velocity.magnitude > maxSpeed)
        {
            rb.velocity = rb.velocity.normalized * maxSpeed;
        }
    }