bool scanAround() { if (Target) { print("Target on"); return(false); } var LPlayer = GameObject.FindObjectsOfType <HW_Player>(); if (LPlayer.Length == 0) { print("player list is null"); return(false); } //Palyer들을 탐색. 현재 위치와 가장 가까운 player가 타겟이 된다 float dist_player = Mathf.Infinity; foreach (var it in LPlayer) { float tempDist = Vector3.Distance(gameObject.transform.position, it.transform.position); //새로 탐색한 것과 거리가 더 가깝다면, 우선 순위로 타겟으로 삼는다 if (dist_player > tempDist) { dist_player = tempDist; Target = it; } } return(true); }
private void Awake() { //detectRadius = 10.0f; min_Range = 0.0f; LEneimies.AddLast(this); fireTimer = 0.0f; rotateTimer = 0.0f; speed = 0.3f; hp = 10.0f; damage = 5.0f; Target = null; }