public void AttemptMove() { if (turnSpeed != turnSpeedCounter) { turnSpeedCounter++; return; } turnSpeedCounter = 1; CalculateObstacles(); path = ABPath.Construct(movingToPoint.position, target.position, null); path.traversalProvider = traversalProvider; AstarPath.StartPath(path); path.BlockUntilCalculated(); if (!path.error) { if (path.vectorPath.Count > 2) { movingToPoint.position = path.vectorPath[1]; blocker.BlockAt(path.vectorPath[1]); path.vectorPath.RemoveAt(0); } else if (path.vectorPath.Count <= 2 && target == FindObjectOfType <PlayerMovePoint>().transform) { //ATTACK PLAYER Health playerHealth = FindObjectOfType <PlayerMovement>().GetComponent <Health>(); playerHealth.DecreaseHealth(GetComponent <DamageDealer>().GetDamage()); } } }