2021년 4학년 1학기 기업연계프로젝트2
컴퓨터소프트웨어공학과 <원광투어팀>
팀장 : 송유진
팀원 : 김나영, 이경희, 한유진
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using System.Collections.Generic;using UnityEngine;
namespace Unity.FPS.AI{ public class PatrolPath : MonoBehaviour { [Tooltip("Enemies that will be assigned to this path on Start")] public List<EnemyController> EnemiesToAssign = new List<EnemyController>();
[Tooltip("The Nodes making up the path")] public List<Transform> PathNodes = new List<Transform>();
void Start() { foreach (var enemy in EnemiesToAssign) { enemy.PatrolPath = this; } }
public float GetDistanceToNode(Vector3 origin, int destinationNodeIndex) { if (destinationNodeIndex < 0 || destinationNodeIndex >= PathNodes.Count || PathNodes[destinationNodeIndex] == null) { return -1f; }
return (PathNodes[destinationNodeIndex].position - origin).magnitude; }
public Vector3 GetPositionOfPathNode(int nodeIndex) { if (nodeIndex < 0 || nodeIndex >= PathNodes.Count || PathNodes[nodeIndex] == null) { return Vector3.zero; }
return PathNodes[nodeIndex].position; }
void OnDrawGizmosSelected() { Gizmos.color = Color.cyan; for (int i = 0; i < PathNodes.Count; i++) { int nextIndex = i + 1; if (nextIndex >= PathNodes.Count) { nextIndex -= PathNodes.Count; }
Gizmos.DrawLine(PathNodes[i].position, PathNodes[nextIndex].position); Gizmos.DrawSphere(PathNodes[i].position, 0.1f); } } }}
|