public override void Update() { // Ввод движения inputMove = Input.GetAxis("Vertical"); inputRotate = Input.GetAxis("Horizontal"); Vector3 movement = inputMove * transform.forward * moveSpeed; float rotation = inputRotate * rotationSpeed; playerController.Move(movement); playerController.Rotate(rotation); // Ввод стрельба if (Input.GetKey(KeyCode.X)) { gunController.Shoot(); } if (Input.GetKeyDown(KeyCode.Q)) { gunController.ChangeWeapon(-1); } if (Input.GetKeyDown(KeyCode.W)) { gunController.ChangeWeapon(+1); } // цель камеры находится перед танком по направлению его движения Vector3 cameraTargetVector = transform.forward * cameraTargetOffset; cameraTarget.position = transform.position + cameraTargetVector; }
//vec 正規化された方向ベクトル public void Move(Vector3 vec) { moveController.Move(vec); //アニメーション再生? //向き変更? }
public void Move(Vector3 movement) { if (!_moveInProgress) { _moveInProgress = true; Debug.Log($"PlayerMovementService.Move"); _playerMove.Move(_moveMethod, _playerMove.transform.position + movement, _gameStateManager.CurrentLevelConfig.MoveTime, OnMoveComplete); } else { Debug.Log($"PlayerMovementService: move already is in progress"); } }
void Update() { // Ввод движение inputH = Input.GetAxisRaw("Horizontal"); inputV = Input.GetAxisRaw("Vertical"); if (inputH == 0f && inputV == 0f) { animator.SetBool("run", false); } else { animator.SetBool("run", true); } Vector3 moveInput = new Vector3(inputH, 0f, inputV); Vector3 moveVelocity = moveInput.normalized * moveSpeed; playerController.Move(moveVelocity); // Ввод взгляд Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Plane plane = new Plane(Vector3.up, Vector3.up * 1f); float rayDist; if (plane.Raycast(ray, out rayDist)) { Vector3 point = ray.GetPoint(rayDist); playerController.LookAtMouse(point); cross.position = point; cameraTarget.position = Vector3.Lerp(transform.position, cross.position, 0.1f); } // Ввод прыжок if (Input.GetKeyDown(KeyCode.Space)) { playerController.Jump(); } // Ввод стрельба if (Input.GetMouseButton(0)) { animator.Play("IDLE_SHOOT"); //gunController.CmdShoot(); } }