- Home /
 
Trouble with the third person player movement in the direction of the camera.
 float targetAngle = Mathf.Atan2(moveVec.x, moveVec.z) * Mathf.Rad2Deg + followCamera.eulerAngles.y;
 float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime);
 transform.rotation = Quaternion.Euler(0f, angle, 0f);
 
               This is the code I am currently using in order to make character facing in the direction of the camera. Also, I am using CinemachineFreeLook, rigidbody and capsule collider.
When I moved player using
 moveVec = new Vector3(h, 0, v).normalized;
 transform.Translate(moveDir.normalized * speed * Time.deltaTime);
 
               It works fine, but the problem is, when I press S to make the character to move backwards, it still moves towards the direction that the camera is facing.
How can I make the player to actaully move backwards whilst the camera as well as the character are facing forward?
https://www.youtube.com/watch?v=537B1kJp9YQ&t=338s
The above video is the exact movement that I want to achieve!
               Comment
              
 
               
              Your answer