Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Episode 10 - threading/Assets/Scripts/Unit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ IEnumerator FollowPath() {
transform.LookAt (path.lookPoints [0]);

float speedPercent = 1;

int pathHash = path.GetHashCode();

while (followingPath) {
Vector2 pos2D = new Vector2 (transform.position.x, transform.position.z);
Expand Down Expand Up @@ -82,6 +84,11 @@ IEnumerator FollowPath() {

yield return null;

// Check if the path has changed
if (path.GetHashCode() != pathHash) {
followingPath = false;
}

}
}

Expand Down