DevLog: Week 11 Randomness and AI
Week 11 shifted the focus from player-controlled logic to autonomous systems. To make game worlds feel "alive," I explored the intersection of Artificial Intelligence and Mathematical Randomness, primarily utilizing Unity’s NavMesh system to handle complex spatial navigation.
The goal was to move beyond static environments and engineer entities that can perceive, reason, and move within a 3D space.
Technical Highlights:
NavMesh & Agent Pathfinding: I implemented NavMeshAgents to handle autonomous movement. By baking a NavMesh onto my ProBuilder environments, I enabled agents to calculate the shortest path to a destination while automatically avoiding obstacles.
State-Driven AI Logic: Combining NavAgents with the State Machine patterns from Week 5, I built a "Patrol and Chase" system.
Patrol State: The AI moves between a series of randomized waypoints.
Chase State: If the player enters a specific trigger radius (using the spatial logic from Week 2), the agent re-calculates its path to target the player's position in real-time.
Controlled Randomness: I used
Random.Rangeand Weighted Randomness to prevent AI behavior from feeling robotic. This includes randomized idle times between patrol points and varied movement speeds, creating a more organic and unpredictable environment.Mathematical Perception: I applied Vector Mathematics (specifically
Vector3.Distanceand Dot Products) to determine the AI's "Line of Sight." This ensures the AI only "sees" the player if they are within a certain distance and a specific field-of-view cone.
Reflection: The Complexity of Autonomy
Integrating AI required a deeper understanding of how systems interact. It wasn't just about moving an object; it was about managing performance (ensuring pathfinding isn't too taxing) and logic (ensuring states transition smoothly). For my portfolio, this demonstrates the ability to create dynamic, interactive systems that respond to player behavior without direct input.