Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace RPG.Control
- {
- public class PatrolPath : MonoBehaviour
- {
- // Variables
- const float waypointGizmoRadius = 0.3f;
- private void OnDrawGizmos()
- {
- for(int i = 0; i < transform.childCount; i++)
- {
- int j = GetNextIndex(i);
- Gizmos.DrawSphere(GetWaypoint(i), waypointGizmoRadius);
- Gizmos.DrawLine(GetWaypoint(i), GetWaypoint(j));
- }
- }
- public int GetNextIndex(int i)
- {
- if(i + 1 == transform.childCount)
- {
- return 0;
- }
- return i + 1;
- }
- public Vector3 GetWaypoint(int i)
- {
- return transform.GetChild(i).position;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment