unity face movement direction code example
Example 1: unity face direction of movement
transform.rotation = Quaternion.LookRotation(dir);
Example 2: how to make an object face the movement direction in unity
float moveHorizontal = Input.GetAxisRaw ("Horizontal"); float moveVertical = Input.GetAxisRaw ("Vertical"); Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical); transform.rotation = Quaternion.LookRotation(movement); transform.Translate (movement * movementSpeed * Time.deltaTime, Space.World);