Professional Documents
Culture Documents
A Pathfinding Agent - Project Report
A Pathfinding Agent - Project Report
A Pathfinding Agent - Project Report
PROJECT REPORT
1. Introduction:
The purpose of this project was to develop a path finding agent using the A* (A-star) algorithm,
implemented with the Unity Nav Mesh Agent component. The project aimed to create an
intelligent agent capable of navigating through complex environments and finding the optimal
path from a starting point to a goal point. This report provides an overview of the project,
including its goals, methodology, implementation details, and results.
2. Project Goals:
The primary goals of the project were as follows:
Utilize the Unity Nav Mesh Agent to enable realistic navigation within the game
environment.
Implement a user-friendly interface for specifying the start and goal points.
Evaluate the performance and effectiveness of the path finding agent in different scenarios.
Designing the navigation environment: A virtual game environment was created using
the Unity engine, consisting of obstacles, terrain, and the path finding agent.
Integrating the Unity Nav Mesh Agent: The Unity Nav Mesh Agent component was
utilized to enable smooth and realistic navigation for the path finding agent.
Testing and evaluation: The path finding agent was tested and evaluated in various
scenarios to assess its performance, efficiency, and accuracy.
4. Levels
4.1 Level 1: Basic Pathfinding
The first level showcased the agent's ability
to navigate through a simple maze. The
maze contained walls and corridors, and the
agent had to find the shortest path from its
starting position to the goal. The A* algorithm
efficiently computed the optimal path, and the
Nav Mesh Agent guided the agent through
the maze, avoiding obstacles and walls.
void Update()
{
if (Input.GetMouseButtonDown(0))
{
RaycastHit hit;
The Nav Mesh Agent was responsible for the movement of the path finding agent. It took
care of path calculation, obstacle avoidance, and smooth movement. By utilizing the Nav
Mesh Agent, the agent could navigate around dynamic obstacles, such as other moving
entities, while still maintaining the overall path finding goal.
5.3 Heuristics:
Heuristics played a crucial role in the A* algorithm by providing an estimate of the remaining
cost from a given node to the goal node. Different heuristics could be used, such as
The graph representation also facilitated the integration of the Unity Nav Mesh Agent
component. The NavMesh baking process generated the navigation mesh, which was
essentially a pre-computed graph that the Nav Mesh Agent used for navigation. The Nav
Mesh Agent could then navigate through the nodes and edges of the NavMesh, avoiding
obstacles and finding the optimal path.
On the level selection screen, two buttons were included. The first button was the "Back"
button, which allowed the user to return to the main menu and select a different level.
This feature ensured flexibility and allowed users to explore various levels without having
to close and reopen the game.
The second button on the level selection screen was the "+" button, which allowed the
user to add more AI agents to the scene. By clicking this button, the user could
dynamically increase the number of AI agents present in the level, enhancing the
complexity and challenge of the gameplay. This feature added an element of
customization and provided the user with control over the number of AI agents they
wanted to interact with.
The UI elements on the level selection screen were designed to be visually appealing
and easy to understand, contributing to a seamless and immersive user experience.
// Rotate the object around its up axis (Y-axis in Unity) at the specified speed
transform.Rotate(Vector3.up, rotationSpeed * Time.deltaTime);
By incorporating dynamic obstacles, the project provided a more realistic and challenging
environment for the path finding agent. The agent had to adapt its path dynamically to
avoid colliding with these moving obstacles, adding an additional layer of complexity to
the path finding process.
The line renderer script was designed to update dynamically as the agent moved or if the
target location changed. This allowed the player to visualize the agent's planned path in
real-time, assisting in decision-making and understanding the path finding process.
isVisible = !isVisible;
lineRenderer.enabled = isVisible;
By incorporating these additional features and scripts, the project provided a more
immersive and interactive experience for the player. The movement of dynamic obstacles
added complexity, the camera follow and zoom functionality improved visibility and
control, and the line renderer enhanced the visual feedback, all contributing to a more
engaging and enjoyable gameplay experience.
In the first level (Maze), the agent efficiently found the optimal path through the maze,
avoiding walls and obstacles.
In the third level (Dynamic Obstacles), the agent showcased its ability to dynamically adjust
its path to avoid collisions with moving obstacles while still finding the optimal route to the
goal.
Path Efficiency: The agent consistently found the shortest path from the starting point to
the goal, minimizing unnecessary movements and avoiding obstacles.
Real-time Adaptability: The agent effectively adjusted its path in real-time to avoid
dynamic obstacles, ensuring smooth navigation even in a changing environment.
Smooth Movement: The agent moved smoothly and realistically, demonstrating natural
navigation behavior while traversing different surfaces and obstacles.
Overall, the pathfinding agent met the project's objectives by successfully navigating through
different levels and handling various obstacles using the A* algorithm and the Unity Nav Mesh
Agent.
8. Future Enhancements:
While the project has achieved its intended goals, there are several avenues for future
enhancements and further exploration. Some potential areas for improvement and expansion
include:
Introducing additional path finding algorithms to compare and evaluate their performance
against the A* algorithm.
Incorporating machine learning techniques to train the path finding agent and enable
adaptive behavior in dynamic environments.
Expanding the game environment with more complex layouts, terrain features, and
interactive elements to provide a richer and more immersive experience.
Enhancing the user interface to provide more customization options, visual feedback, and
user-friendly controls.
By pursuing these future enhancements, the project can be further improved and extended,
leading to more advanced and sophisticated path finding systems within Unity-based
applications and beyond.
9. Conclusion
The development of the pathfinding agent using the A* algorithm and Unity Nav Mesh Agent
proved to be a successful project. The agent exhibited impressive pathfinding capabilities in
different scenarios, including basic mazes, off-mesh links, stairs, slopes, and moving obstacles.
The integration of the A* algorithm with the Nav Mesh Agent component provided efficient and
optimized pathfinding functionality, enabling the agent to find the optimal paths while avoiding
obstacles.
The project demonstrated the importance of pathfinding algorithms and navigation systems in
creating intelligent and interactive game environments. The implemented levels showcased the
versatility and adaptability of the pathfinding agent, highlighting its ability to handle complex
situations and find optimal paths.