0

Unity で 3 人称コントローラーを作成していますが、行き詰まっています。フリールック シネママシンにプレーヤーを追従させる方法がわかりません。

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public float speed;
    public GameObject Hoverboard_script;
    public GameObject cinemachine_Hoverboard;
    public Transform main_cam_tf;

    void Update()
    {
        Hoverboard_script.SetActive(false);
        cinemachine_Hoverboard.SetActive(false);
        PlayerMovement_void();
        CamController_void();
    }

    void PlayerMovement_void()
    {
        float hor = Input.GetAxisRaw("Horizontal");
        float ver = Input.GetAxisRaw("Vertical");
        Vector3 playerMovement = new Vector3(hor, 0f, ver).normalized * speed * Time.deltaTime;
        transform.Translate(playerMovement, Space.Self);
    }

    void CamController_void()
    {
        float MouseY = main_cam_tf.eulerAngles.y;
        Debug.Log(MouseY);
        Quaternion rotation = Quaternion.Euler(0f, MouseY, 0f);
        transform.rotation = Quaternion.Lerp(transform.rotation, rotation, Time.deltaTime * 4f);
    }
}

現在、カメラを回転させると、プレーヤーはノンストップ ループに入り、常に回転します。どうすれば解決できますか?ありがとう、乾杯

4

0 に答える 0