This is a long recipe that could be regarded as a big two-step process. First, we build the Path class, which abstracts points in the path from their specific spatial representations, and then we build the PathFollower behavior that makes use of that abstraction in order to get actual spatial points to follow:
- Create the Path class, which consists of nodes and segments; only the nodes are public and are assigned manually:
using UnityEngine; using System.Collections; using System.Collections.Generic; public class Path : MonoBehaviour { public List<GameObject> nodes; List<PathSegment> segments; }
- Define the Start function to set the segments when the scene starts:
void Start() { segments = GetSegments(); }
- Define the ...