0
0
Unityframework~10 mins

Waypoint systems in Unity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a list of waypoints.

Unity
public List<Transform> [1];
Drag options to blanks, or click blank then click option'
Awaypoints
Bpoints
Ctargets
Dnodes
Attempts:
3 left
💡 Hint
Common Mistakes
Using a singular name for a list
Using unrelated variable names
2fill in blank
medium

Complete the code to move the object towards the current waypoint.

Unity
transform.position = Vector3.MoveTowards(transform.position, [1].position, speed * Time.deltaTime);
Drag options to blanks, or click blank then click option'
AnextPoint
Btarget
Cwaypoints[currentIndex]
Ddestination
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable not defined
Using just the list name without index
3fill in blank
hard

Fix the error in the code that checks if the object reached the waypoint.

Unity
if (Vector3.Distance(transform.position, [1].position) < 0.1f) { currentIndex++; }
Drag options to blanks, or click blank then click option'
Awaypoints[currentIndex + 1]
Bwaypoints[currentIndex]
Cwaypoints[0]
Dwaypoints[lastIndex]
Attempts:
3 left
💡 Hint
Common Mistakes
Using an index out of range
Using the wrong waypoint index
4fill in blank
hard

Fill both blanks to loop the waypoint index correctly.

Unity
if (currentIndex >= [1].Count) { currentIndex = [2]; }
Drag options to blanks, or click blank then click option'
Awaypoints
B0
C1
DwaypointList
Attempts:
3 left
💡 Hint
Common Mistakes
Resetting to 1 instead of 0
Using wrong list name
5fill in blank
hard

Fill all three blanks to create a dictionary mapping waypoint names to their positions if the position's x is greater than 0.

Unity
var waypointDict = new Dictionary<string, Vector3>() { { [1], [2] } for int i = 0; i < waypoints.Count; i++ if (waypoints[i].position.x [3] 0) };
Drag options to blanks, or click blank then click option'
Awaypoints[i].name
Bwaypoints[i].position
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using position as key
Using wrong comparison operator
Using wrong variable