private void Update() { foreach (Vector3 point in _points) { DebugExtension.DebugPoint(point); } ResetInput(); if (Vector3.Distance(transform.position, target.position) > .5f) { Vector2 targetDir = target.position - transform.position; float bestAngle = float.MaxValue; //TODO make smarter RegisteredMove bestMove = null; foreach (var move in registeredMoves) { if (!move.checkCondition()) { continue; } float angle = Vector2.Angle(targetDir, move.direction); if (angle < bestAngle) { bestAngle = angle; bestMove = move; } } bestMove?.doMove(bestMove.distanceToDuration(targetDir.magnitude)); //print(bestMove?.name); } }