0
0
Unityframework~10 mins

Pathfinding basics 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 variable for the target position.

Unity
public Vector3 [1];
Drag options to blanks, or click blank then click option'
AtargetPosition
BstartPosition
Cagent
Dspeed
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names unrelated to position like 'speed' or 'agent'.
2fill in blank
medium

Complete the code to get the NavMeshAgent component attached to the GameObject.

Unity
agent = GetComponent<[1]>();
Drag options to blanks, or click blank then click option'
ATransform
BNavMeshAgent
CCollider
DRigidbody
Attempts:
3 left
💡 Hint
Common Mistakes
Using Rigidbody or Collider which are unrelated to pathfinding.
3fill in blank
hard

Fix the error in setting the destination for the NavMeshAgent.

Unity
agent.[1](targetPosition);
Drag options to blanks, or click blank then click option'
ASetDestination
BGoTo
CMove
DNavigate
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like Move or GoTo.
4fill in blank
hard

Fill both blanks to check if the agent has reached its destination.

Unity
if (agent.[1] <= agent.[2]) {
    Debug.Log("Destination reached");
}
Drag options to blanks, or click blank then click option'
AremainingDistance
BstoppingDistance
Cspeed
Dradius
Attempts:
3 left
💡 Hint
Common Mistakes
Using speed or radius instead of distance properties.
5fill in blank
hard

Fill all three blanks to create a dictionary mapping waypoint names to their positions, filtering only waypoints within 10 units.

Unity
var waypoints = new Dictionary<string, Vector3>() {
    {"Start", [1],
    {"Middle", [2],
    {"End", [3]
};
Drag options to blanks, or click blank then click option'
Anew Vector3(0, 0, 0)
Bnew Vector3(5, 0, 5)
Cnew Vector3(10, 0, 10)
Dnew Vector3(15, 0, 15)
Attempts:
3 left
💡 Hint
Common Mistakes
Including points too far away like (15,0,15).