Curriculum
Course: How to develop 3D Games with Unity
Login
Video lesson

Enemies – Part 2 – Dynamic Observers

Summary

You’ve created one enemy John Lemon has to avoid, but that doesn’t seem like much of a challenge. It’s time to create another enemy that will increase the challenge for the player.

In this tutorial, you’ll:

  • Create a dynamic Ghost enemy
  • Write a custom script so Ghosts can patrol the haunted house
  • Populate your game with enemies
  • When you’ve finished the tutorial, your game will be full of enemies — and almost complete!

Objectives

  1. Implement a Moving Ghost Enemy: Introduce a dynamic ghost enemy into the game, capable of moving within the environment.
  2. Animate and Script the Ghost: Ensure the ghost has appropriate animations and scripts for dynamic interaction.
  3. Utilize Pathfinding: Set up pathfinding for the ghost using waypoints, allowing it to patrol and navigate the game environment.
  4. Test and Adjust Gameplay: Conduct gameplay testing to fine-tune the ghost’s movements and interactions for an optimal player experience.

Steps

Top of Form

  1. Create a New Scene: Save the current progress in a new scene for easy reference and further research.
  2. Setup Ghost Prefab: Locate and add the ghost model from the project assets to the hierarchy. Convert it into a prefab for editing.
  3. Animate the Ghost: Create a new animator controller named ‘Ghost’. Assign relevant animations, such as ‘Ghost Walk’, to this controller.
  4. Configure Animator Controller: Assign the newly created animator controller to the ghost in the inspector.
  5. Add Collider to Ghost: In prefab mode, attach a capsule collider to the ghost and adjust its properties like center, radius, and height.
  6. Implement Rigid Body: Add a rigid body component to the ghost and set it as kinematic for movement control.
  7. Setup Ghost as an Observer: Utilize the ‘Point of View’ prefab to make the ghost an observer, similar to the gargoyle setup in the previous tutorial.
  8. Configure Nav Mesh Agent: Add a Nav Mesh Agent component to the ghost for pathfinding capabilities.
  9. Create and Assign Waypoints: Develop waypoints to guide the ghost’s patrol route and assign them to the ghost’s pathfinding system.
  10. Organize Game Objects: Clean up the hierarchy by organizing ghosts, gargoyles, and waypoints under respective parent objects for clarity.
  11. Test the Scene: Run the game to observe the ghost’s dynamic behavior and interactions.
  12. Troubleshoot and Debug: Address any issues, such as the ghost not appearing or moving as expected, and make necessary adjustments.
  13. Save Progress: Regularly save the scene to preserve changes and facilitate further research and development.