So I want to implement camera based movement in this function, but no tutorials really help me.
I want to move like in all 3rd person games, if I look somewhere and press W character will move
in that direction.
Thanks in advance, if you will help me.
private void Movement()
{
float verticalAxis = Input.GetAxis("Vertical");//varies between 1 and -1
float horizontalAxis = Input.GetAxis("Horizontal");
//create a new vector
Vector3 updatedVector = new Vector3(horizontalAxis, 0.0f, verticalAxis);//new position that has been changed through axis
transform.LookAt(updatedVector + transform.position);//facing towards vector
animator.SetBool("Is_Running", true);//setting animator boolean
transform.Translate(updatedVector * speed * Time.deltaTime, Space.World);//actual movement
if(verticalAxis == 0 && horizontalAxis == 0)//if player doesn't move
{
animator.SetBool("Is_Running", false);
}
}
}