private void Move() { if (!CanMove) { return; } MovementUpdate?.Invoke(_moveDirection, _speed); var position = transform.position; _rigidbody.MovePosition(position + (_moveDirection * _speed * Time.fixedDeltaTime)); _ground.SetNormalAndPosition(Vector3.up, new Vector3(0f, position.y, 0f)); }
private void Movement() { if (!CanMove) { return; } var moveDirection = (_fixedAxisMovement ? Vector3.right : transform.right) * Input.GetAxis("Horizontal") + (_fixedAxisMovement ? Vector3.forward : transform.forward) * Input.GetAxis("Vertical"); if (moveDirection.magnitude >= 1f) { moveDirection = moveDirection.normalized; } MovementUpdate?.Invoke(moveDirection, _speed); _characterController.Move(moveDirection * (_speed * Time.deltaTime) + _gvelocity * Time.deltaTime); _ground.SetNormalAndPosition(Vector3.up, new Vector3(0f, transform.position.y, 0f)); }