Home || Previous || Next

Creating an NPC which finds a player

  1. Create a 3D Project in Unity
  2. Create Plane (world)
  3. Create cubes (Wall)
  4. Select all and make staticScreen Shot 2015-11-19 at 10.24.12.png
  5. Go to navigation windowScreen Shot 2015-11-19 at 10.26.02.png
  6. Select the world – Click Bake Screen Shot 2015-11-19 at 10.27.10.png
  7. Create cube and call in NPC which needs a rigid body and Navmesh agent.Screen Shot 2015-11-19 at 10.30.42.png
  8. Nav Mesh Agent changes the way the NPC moves: base offset moves the characters height, stopping distance is another good one to change.
  9. Create a cylinder and call it Player, add tag of player.Screen Shot 2015-11-19 at 10.34.55.png
  10. Create script – Pathfinder in c SharpScreen Shot 2015-11-19 at 10.36.51.png
  11. Define Game Object and set it to Player. Then Define NavMesh Agent and attache it to the NavMesh AgentScreen Shot 2015-11-19 at 10.40.15.png
  12. Set the naavMeshAgent to the players transform position (this requires a Vector3)Screen Shot 2015-11-19 at 10.42.30.png
  13. Add the script to NPC thus allowing it to navigate to player.Screen Shot 2015-11-19 at 10.44.21.png
  14. Change stopping distance to stop the NPC pushing the player.

Creating a NPC which patrols

  1. Getting the NPC to patrol
  2. Create objects with no meshScreen Shot 2015-11-19 at 10.49.26.png
  3. The NPC will still find the object
  4. You could have multiple of these objects and use an array to call them in order.
  5. Creating a patrolling npc


Understanding the A* Principle



Home || Previous || Next