Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

issues with the 3rd person controller tutorial

I was recently creating a third person controller for my object and followed the new brackeys tutorial exactly. My Cinemachine Camera works fine. set it up exactly like in the video, setting binding to "World Space" and all the other values appropriately. However no mater what I do, the player will not move in the direction of the camera. The direction for forward and backwards movement is always the same regardless of where the camera is facing. Also, when I press A and D to go to the side, the object quickly flickers between facing the front and side. Was wondering if anyone else has had problems like this with the third person controller. Here's my code.

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class thirdPersonMovement : MonoBehaviour


    public CharacterController controller;

    public Transform cam;

    // Start is called before the first frame update


    public float speed = 6f;

    public float turnSmoothTime = 0.1f;

    public float turnSmoothVelocity;

    void Start()




    // Update is called once per frame

    void Update()


        float horizontal = Input.GetAxisRaw("Horizontal");

        float vertical = Input.GetAxisRaw("Vertical");

        Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;

        if (direction.magnitude >= 0.1f)


            float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg * cam.eulerAngles.y;

            float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime);

            transform.rotation = Quaternion.Euler(0f, angle, 0f);


            Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward;


            controller.Move(moveDir.normalized * speed * Time.deltaTime);




Sign In or Register to comment.