I want to use the character’s local direction and in other hand i try to make the character’s face return the clicked direction.
But as a beginner i stuck at some point and need help. The code that i mentioned has no problem with face return but it is not goes player’s local direction. I tried but can’t implemented transform.transformdirection
method.
void Movement()
{
Vector2 inputVector = new Vector2(0, 0);
if (Input.GetKey(KeyCode.W))
{
inputVector.y += 1;
}
if (Input.GetKey(KeyCode.S))
{
inputVector.y -= 1;
}
if (Input.GetKey(KeyCode.A))
{
inputVector.x -= 1;
}
if (Input.GetKey(KeyCode.D))
{
inputVector.x += 1;
}
inputVector.Normalize();
Vector3 moveDir = new Vector3(inputVector.x, 0, inputVector.y);
transform.position += moveDir * Time.deltaTime * moveSpeed;
transform.forward = moveDir;
}