Creating an NPC which finds a player
- Create a 3D Project in Unity
- Create Plane (world)
- Create cubes (Wall)
- Select all and make static
- Go to navigation window
- Select the world – Click Bake
- Create cube and call in NPC which needs a rigid body and Navmesh agent.
- Nav Mesh Agent changes the way the NPC moves: base offset moves the characters height, stopping distance is another good one to change.
- Create a cylinder and call it Player, add tag of player.
- Create script – Pathfinder in c Sharp
- Define Game Object and set it to Player. Then Define NavMesh Agent and attache it to the NavMesh Agent
- Set the naavMeshAgent to the players transform position (this requires a Vector3)
- Add the script to NPC thus allowing it to navigate to player.
- Change stopping distance to stop the NPC pushing the player.
Creating a NPC which patrols
- Getting the NPC to patrol
- Create objects with no mesh
- The NPC will still find the object
- You could have multiple of these objects and use an array to call them in order.
- Creating a patrolling npc
Understanding the A* Principle