private void Update() { FaceTarget(); if (Vector3.Distance(transform.position, playerTransform.position) <= distToDash && !attacking && directionFinder.IsFrontTrajectoryCleared()) { pathFinder.StopPathing(); Dash(); } }
private void Update() { FaceTarget(); float distToPlayer = Vector3.Distance(transform.position, playerTransform.position); if (distToPlayer < distToShield + 1 && distToPlayer > distToPlayer - 1) { attacking = true; if (activatePathing) { activatePathing = false; pathFinder.StopPathing(); } if (right) { body.velocity = directionFinder.GetRightDirection().normalized *walkShieldingSpeed *Time.fixedDeltaTime; } else { body.velocity = directionFinder.GetLeftDirection().normalized *walkShieldingSpeed *Time.fixedDeltaTime; } } else { attacking = false; if (!activatePathing) { activatePathing = true;; pathFinder.StartNewPath(); } } Shield(); }