Menu

Tree [838736] main /
 History

HTTPS access


File Date Author Commit
 .github 2023-04-02 Bapon Kar Bapon Kar [a05e0b] Update issue templates
 .vs 2023-11-06 Bapon Kar Bapon Kar [cbcf95] New Romero added
 .vscode 2022-08-05 Bapon Kar Bapon Kar [1617d2] Change Project
 Assets 2023-11-06 Bapon Kar Bapon Kar [3ec2b8] unnecessary screenshots deleted
 Logs 2024-05-27 Bapon Kar Bapon Kar [db10ff] updating README.md
 Packages 2023-11-06 Bapon Kar Bapon Kar [cbcf95] New Romero added
 ProjectSettings 2023-11-06 Bapon Kar Bapon Kar [3ec2b8] unnecessary screenshots deleted
 ScreenShots 2024-05-27 Bapon Kar Bapon Kar [0fc2ce] Add files via upload
 UserSettings 2024-05-27 Bapon Kar Bapon Kar [07a739] updating README.md
 .gitattributes 2023-07-12 Bapon Kar Bapon Kar [f1fb9f] Robot prefab added
 .gitignore 2022-08-05 Bapon Kar Bapon Kar [1617d2] Change Project
 .vsconfig 2023-01-07 Bapon Kar Bapon Kar [f12833] Behavior tree deleted...fully statemachine cont...
 Credits.txt 2022-08-05 Bapon Kar Bapon Kar [1617d2] Change Project
 LICENSE.md 2022-08-05 Bapon Kar Bapon Kar [578bd1] LICENSE file added
 README.md 2024-05-28 Bapon Kar Bapon Kar [838736] Update README.md
 README.txt 2023-05-30 Bapon Kar Bapon Kar [93abb5] Animation fixed
 wiki.html 2024-05-27 Bapon Kar Bapon Kar [b601a4] Add files via upload

Read Me

Unity Badge
FPS
CSharp Badge
Issue
fork
star
LicenseWiki Badge

Share icon

Social Picture Banner

Zombie NPC or Zombie AI for Unity Game Engine

  • A Fully State Machine and ~Behavior Tree~ controlled advanced Zombie Non Playable Character(NPC) or AI for Unity Project with a Demo Scene.You can use this asset for your Game development.You can use the given states or introduced your own new state then you need to import the corresponding state animation and state transition logic. You also can use the zombie prefab for any kind mesh character by importing corresponding mesh and animation.

See following demo videos :
* YouTube demo Badge

Roughly It has 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

Screenshots:

Screenshot 0Screenshot 1Screenshot 2Screenshot 2

Flowchart of State Transition


Flowchart of State transition

You can make your own custom transition then you need to update the state csharp script files according to your logic.

Behavior Tree:

I have dropped this feature.
Behavior Tree

Documentation :

  • You can see scene setup tutorial on Wiki Badge or included PDF file.

  • This is a complete Unity Project with included depending assets and also included a Demo Scene.

  • If You download this project and open it with Unity then it may works perfectly but sometimes may not works the way because of layers absence in the project then you need to add corresponding layers and set by the below instruction.

  • If you use this project with your old project then first put '_Zombie_ai_Fsm' folder in your project then create and add the layers in your project by below instruction.
    Zombie NPC is a navmesh agent which detect player by using vision sensor and sound sensor.Vison Sensor have a sensory memory to memorize sense which can be set by config scriptable object.

  • vison sensor can sense Character layers which is attached to the player prefab.

  • The NPC Zombie have different inter related states you can manage those states by set up in config scriptable object found in the project.

* Project setup instructions:

  1. Add following layers in the following orders

  2. [x] Layer 3 - Player

  3. Layer 6 - NPC
  4. Layer 13 - Character
  5. [x] Layer 14 - Mini Map

  6. NPC : Change Default layer of Zombie/Romero Prefab into NPC, and also
    Change Tag of Zombie/Romero Prefab into NPC.

  7. Change Layer of Player into Character which will be seen by NPCs, and also
    Change Tag of Player with "Player".

  8. Change Layer of all prefabs indicator plane into "Mini Map" Layer.Which will be seen only by Mini Map Camera.

  9. See NPCVisionSensor Script which attached with npcs i.e. zombie/Romero prefabs and change its Occulation Layer with corresponding
    Ground Layer i.e. if ground plain be Defult then change into Defult Layer.

  10. See NPCVisionSensor.cs Script which attached with npcs i.e. zombie/Romero prefabs and change its Target Layer into Character Layer which is the Layer of Player.So NPCs can see the player by vision sensor.

  11. Bake Navmesh with Humanoid Agent which should be in NavMeshAgent(Which attached to the Zombie Prefab).

  12. Now put zombie prefab and player prefab in your scene.Player has attached a Health script which is damageable by Zombie/Romero.

  13. 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.

  14. Change or tweak zombie behavior by setting up zombie config scriptable object.

  15. To Change custom sensor detection layer edit 'NPCSensoryMemory.cs' file

  16. 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

Zombie sensor sense Character Layer for this NPCSensoryMemory.cs Script.

Find "NPCSensoryMemory.cs" Script inside Scripts folder.
* Zombie_Ai
* Assets
- Zombie_ai
- Zombie_NPC
- Scripts
- NPCSensoryMemory.cs

   ...
   public void UpdateSenses(NPCVisionSensor sensor)
   {
      int targets = sensor.Filter(characters, 'TargetLayer');
      //Here put the player layer name in 'TargetLayer'
      //Here I have use 'Character' as Player Object Layer is that.
      ....
   }

Changing Target Layer

  • This Project has a Demo Scene with necessary setup.

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

  5. Mixamo Character

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.

  8. I have put all the above packages file and folder inside of this project.

Unity Version

Unity 2020.3.15f2 or higher version.

Contact:

Gmail
X
LinkedIn
YouTube


Copyright © baponkar 2024

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.