public PatrolMission(SneakEnemyPatrol pEnemy) { enemy = pEnemy; target = RandomizeNewTarget(); CheckFinished = () => { float distance = Vector2.Distance(enemy.transform.position, target); if (distance > lastDistance) { enemy.transform.position = new Vector2(target.x, enemy.transform.position.y); // Randomize new target target = RandomizeNewTarget(); lastDistance = 100000f; return(true); } else { WalkTowardsTarget(); lastDistance = distance; return(false); } }; }
public PatrolMission(SneakEnemyPatrol pEnemy) { enemy = pEnemy; target = RandomizeNewTarget(); CheckFinished = () => { float distance = Vector2.Distance(enemy.transform.position, target); if(distance > lastDistance) { enemy.transform.position = new Vector2(target.x, enemy.transform.position.y); // Randomize new target target = RandomizeNewTarget(); lastDistance = 100000f; return true; } else { WalkTowardsTarget(); lastDistance = distance; return false; } }; }