HugoFang / zombie-ai

Zombie AI for Unity with State Machine and Behavior Tree Controlled.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unity 2020 Badge FPS C# Issue fork star License

Zombie AI for Unity Engine .

A FSM and Behavior Tree based Zombie NPC Unity Project with a Demo Scene.See

It has roughly following Characteristics:

  • Zombie - Idle State.
  • Zombie - Chasing Player State
  • Zombie - Patrolling State
  • Zombie - Attack State
  • Zombie - Flee State
  • Zombie - Dead State
  • Zombie State - Waypoint based Patrolling.
  • Zombie - Call Near NPC to attack Player
  • State Control by Behavior Tree
  • Statemachine[Both prefab have]
  • Zombie - Sound Sensor
  • Zombie - Vison Sensor
  • Sensor Memory for Target
  • FPS Player
  • A Demo Scene
  • Walking Audio
  • Camera Shake

ScreenShots0

ScreenShots1

ScreenShots1

Behavior Tree

ScreenShots of behavior tree

ScreenShots of behavior tree

Doc :

This is complete Unity Project if You download this project and open it then it will works perfectly. If you use this project with your old project then first put 'Asset' folder in your project. Zombie NPC is a navmesh agent which detect player by using vision sensor and sound sensor.


  1. Add following layers in the following orders Layer 3 - Player,Layer 6-NPC 13-Character, Layer 14-Mini Map
  2. NPC : Change Default layer to NPC layer on Zombie Prefab. Change Tag NPC of Zombie Prefab.
  3. Player : Change "Default" layer to "Character" layer on Player Prefab. All indicator plane need to change into "Mini Map" Layer Change Tag of Player with "Player"
  4. Ground : Change Default layer to Ground layer on Ground Plain or Terrain or like that envirionment object.
  5. Change Vision Sensor(Which attached to the Zombie Prefab)'s target layer to 'Character'.
  6. Change All Occulation layer of Vision Sensor(Which attached to the Zombie Prefab) to Default,Ground etc all occulation layer have in your scene.
  7. Bake Navmesh with Humanoid Agent which should be in NavMeshAgent(Which attached to the Zombie Prefab).
  8. Now put zombie prefab and player prefab in your scene.Player has attached a Health script which is damageable by Zombie.
  9. Zombie also has attached a Health Script which can be damagable by external player which has a weapon which can be used to damage zombies health.
  10. Change or tweak zombie behavior by setting up zombie config scriptable object.
  11. To Change custom sensor detection layer edit 'NPCSensoryMemory.cs' file
  12. If you don't see the npcs then you need to add 'NPC' layer into the culling mask section of FPSCamera which have attached to theplayer prefab

ScreenShots of behavior tree

  • This Project has a Demo Scene with necessary setup.

License:

GNU GPL v-3.0 License

Credits :

  1. I have get ideas from Youtuber 'Kiwi Coder's tutorials 1 2

  2. I have get ideas from Youtuber 'Dev/GameDevelopment's tutorials

  3. Unity Learn - BehaviorTree

  4. Sound Effect from Pixabay

Dependency

  1. This Assets depend on 'Zombie assets by Pxltiger'. So You need to download this package from Unity assets store along with this Zombie_Enemy_AI assets.
  2. Standard-Assets-Characters I am using Audio files for footstep sound.
  3. Rifle by Game-Ready Studios
  4. Unity Simple FPS by me.
  5. My Behavior Tree by me.
  6. Traffic-System by me.
  7. Kiwi coder Behavior Tree by Kiwi Coder.
  • I have put all the above packages file and folder inside of this project.

Unity Version

Unity 2020.3.15f2 or higher version.

Contact

Twitter Github

About

Zombie AI for Unity with State Machine and Behavior Tree Controlled.

License:GNU General Public License v3.0


Languages

Language:C# 100.0%