Edge‐Detector - UQcsse3200/2026-studio-2 GitHub Wiki

Introduction

The edge detector lets enemies detect the platform edge while performing the chase and wandering task. When it detects an edge, the enemy stops moving, stays as close to the edge as possible, and continues pursuing if the path between the enemy and player reconnects.

How it works:

The edge detector determines the enemy's direction, casts a short ray downward from a position slightly ahead of the enemy, and checks for terrain underneath. If it detects a GROUND or OBSTACLE collider, it considers it safe for the enemy to move there. If it detects no valid terrain, the movement stops, and it assumes there is an edge.

Components:

EdgeDetectTask

The EdgeDetectTask class provides information that lets the function detect whether a safe platform is in front of the enemy.

isGroundAhead

isGroundAhead() is a function within EdgeDetectTask; it first calculates the starting position by adding ForwardDistance. If the direction is less than 0, it's left; if larger, it's right. Since the raycast is being cast vertically, the starting position is slightly raised by 0.5, and the end point is picked beneath the starting position. Then the raycast was used and the fucntion will return a boolean if there is GROUND/OBSTACLE