Question by
RonninLee · Feb 16, 2020 at 12:25 PM ·
c#character controllercharacter movement
Problem making my character walk backward
Hi to all im macking a third person controller and i want to move my character backwards but i dont get it.
Here you have the code what i have! Any suggestion will be apreciated thanks!
void PlayerMovement()
{
horizontalMove = Input.GetAxis("Horizontal");
verticalMove = Input.GetAxis("Vertical");
playerInput = new Vector3(horizontalMove, 0, verticalMove);
playerInput = Vector3.ClampMagnitude(playerInput, 1);
playerAnimatorController.SetFloat("PlayerWalkVelocity", playerInput.magnitude * Speed);
CamDirection();
transform.Translate(playerInput, Space.Self);
playerMove = playerInput.x * camRight + playerInput.z * camForward;
playerMove = playerMove * Speed;
player.transform.LookAt(player.transform.position + playerMove);
SetGravity();
player.Move(playerMove * Time.deltaTime);
}
Comment