Complete the code to make the enemy move between two points.
Vector3 targetPosition = points[[1]].position;
transform.position = Vector3.MoveTowards(transform.position, targetPosition, speed * Time.deltaTime);The enemy starts moving towards the first point, which is at index 0 in the points array.
Complete the code to check if the enemy reached the patrol point.
if (Vector3.Distance(transform.position, points[currentPoint].position) [1] 0.1f) { currentPoint = (currentPoint + 1) % points.Length; }
The enemy is considered to have reached the point if the distance is less than 0.1 units.
Fix the error in the chase code to make the enemy follow the player.
transform.position = Vector3.MoveTowards(transform.position, [1], speed * Time.deltaTime);The MoveTowards method needs a Vector3 position, so we use player.transform.position.
Fill both blanks to make the enemy switch from patrol to chase when close to the player.
if (Vector3.Distance(transform.position, player.transform.position) [1] chaseRange) { isChasing = [2]; }
The enemy starts chasing when the player is within chaseRange, so distance <= chaseRange and isChasing is set to true.
Fill all three blanks to make the enemy stop chasing and resume patrol when the player is far.
if (Vector3.Distance(transform.position, player.transform.position) [1] chaseRange) { isChasing = [2]; currentPoint = [3]; }
The enemy stops chasing when the player is farther than chaseRange, so distance > chaseRange, isChasing is false, and patrol restarts at point 0.