private void Update() { if (!_shouldUpdate) { return; } if (ShouldDoPath) { _characterController.Move(Agent.velocity.magnitude / Agent.speed); } else { _characterController.Move(0f); _shouldUpdate = false; } }
// Update is called once per frame void Update() { if (_playerDied) { return; } axisVector = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); cameraRelative = axisVector.x * _cameraTransform.right + axisVector.z * _cameraTransform.forward; cameraRelative.y = 0; if (axisVector.magnitude > 0) { lerpDirection = Vector3.Lerp(lerpDirection, cameraRelative, Time.deltaTime * _turnSpeed); characterController.Move(lerpDirection, axisVector); } if (Input.GetButtonDown("Action")) { if (characterController.GetClosestVictimInRange() != null && _isInfected) //if have a victom close by, bite ! { //Rotate to the actor. And also character will rotate back. if (!_firstBlood) { _firstBlood = true; PanicStartedEvent.Raise(); } characterController.DoAction(CharacterAction.Bite); } else //else, check if any interactable close by, if so, interact! { IInterractable interactable = characterController.GetClosestInteractable(); if (interactable != null) { interactable.Interract(); } } } else if (_isInfected && Input.GetButtonDown("Fire1")) { if (GetMousePositionOverGround(out _aimPoint)) { Debug.LogWarning("AIMING"); _aimPoint = new Vector3(_aimPoint.x, _aimPoint.y + 1, _aimPoint.z); characterController.DoAction(CharacterAction.Spit); } else { Debug.LogWarning("Huh missed"); } } }