void Moving() { movement = Vector3.zero; if (horInput != 0 || vertInput != 0) { IsMoving = true; movement.x = horInput; movement.z = vertInput; if (!TargetedWalk) { Quaternion tmp = mainCamera.rotation; mainCamera.eulerAngles = new Vector3(0, mainCamera.eulerAngles.y, 0); movement = mainCamera.TransformDirection(movement); //mainCamera.rotation = tmp; direction = Quaternion.LookRotation(movement); movement += transform.forward; movement = movement.normalized * moveSpeed; float camYrotate = Vector3.SignedAngle(movement, mainCamera.forward, Vector3.up); if (InRange(camYrotate, 170)) { cam.AddRotation(-camYrotate * 0.008f); } if (!weapon.IsAttacking) { transform.rotation = Quaternion.Lerp(transform.rotation, direction, rotSpeed * 2 * Time.deltaTime); movement *= Time.deltaTime; } else { float coef = 0.1f; transform.rotation = Quaternion.Lerp(transform.rotation, direction, rotSpeed * 0.5f * Time.deltaTime); movement *= Time.deltaTime * coef; } } else { Quaternion tmp = mainCamera.rotation; mainCamera.eulerAngles = new Vector3(0, mainCamera.eulerAngles.y, 0); movement = mainCamera.TransformDirection(movement); direction = Quaternion.Euler(0, mainCamera.eulerAngles.y, 0); movement = movement.normalized * moveSpeed; if (!targeting.Targeted) { transform.rotation = Quaternion.Lerp(transform.rotation, direction, rotSpeed * Time.deltaTime); cam.AddRotation(horInput * 0.5f); } movement *= Time.deltaTime * 0.3f; } movement.y -= 0.5f; } else { IsMoving = false; } if (movement != Vector3.zero) { _charController.Move(movement); } }