private void Update() { if (Input.GetKey(KeyCode.LeftShift) || animator.IsKicking) { if (!_fighting) { _fighting = true; animator.Fighting = true; } if (!animator.IsKicking && Input.GetKeyDown(KeyCode.F)) { animator.Kick(); } } else { if (_fighting) { _fighting = false; animator.Fighting = false; } var startingPosition = selfTransform.position; var intendedDirection = new Vector3( Input.GetKey(KeyCode.D) ? 1 : Input.GetKey(KeyCode.A) ? -1 : 0, 0, Input.GetKey(KeyCode.W) ? 1 : Input.GetKey(KeyCode.S) ? -1 : 0); if (intendedDirection != Vector3.zero) { var intendedPosition = startingPosition + (intendedDirection.normalized * (Time.deltaTime * speed)); if (NavMesh.SamplePosition(intendedPosition, out var hit, 0.3f, NavMesh.AllAreas)) { selfTransform.position = hit.position; _mainCam.position = hit.position + new Vector3(0, 5.5f, -4.5f); var newYaw = Quaternion.LookRotation(intendedPosition - startingPosition, Vector3.up).eulerAngles.y; selfTransform.eulerAngles = new Vector3(0, newYaw, 0); } } } }
public override void OnExecutionStart() => _animator.Kick();