public void SetPathAndPos(PolyLinePath path, float pathPos, bool rotationStaysInitially = false) { Assert.IsNotNull(path); _path = path; PathPos = pathPos; _pathExists = true; if (PathPos > _path.TotalLength) { Debug.LogError($"pathPos is out of bounds. pathPos: {pathPos}, Path TotalLength: {path.TotalLength}"); } // Set initial rotation _path.GetWorldPosAtPathPos(PathPos, out var direction); if (!rotationStaysInitially) { transform.rotation = Quaternion.LookRotation(direction); } }
public void ClearPath() { _path = null; _pathExists = false; }