- A Fully State Machine and
Behavior Treecontrolled 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 :
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
You can make your own custom transition then you need to update the state csharp script files according to your logic.
-
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:
- Add following layers in the following orders
- Layer 3 - Player
- Layer 6 - NPC
- Layer 13 - Character
- Layer 14 - Mini Map
-
NPC : Change Default layer of Zombie/Romero Prefab into NPC, and also Change Tag of Zombie/Romero Prefab into NPC.
-
Change Layer of Player into Character which will be seen by NPCs, and also Change Tag of Player with "Player".
-
Change Layer of all prefabs indicator plane into "Mini Map" Layer.Which will be seen only by Mini Map Camera.
-
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.
-
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.
-
Bake Navmesh with Humanoid Agent which should be in NavMeshAgent(Which attached to the Zombie Prefab).
-
Now put zombie prefab and player prefab in your scene.Player has attached a Health script which is damageable by Zombie/Romero.
-
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.
-
Change or tweak zombie behavior by setting up zombie config scriptable object.
-
To Change custom sensor detection layer edit 'NPCSensoryMemory.cs' file
-
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
Find "NPCSensoryMemory.cs" Script inside Scripts folder.
- Zombie_Ai
- Assets
- Zombie_ai
- Zombie_NPC
- Scripts
- NPCSensoryMemory.cs
- Scripts
- Zombie_NPC
- Zombie_ai
- Assets
...
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.
....
}
- This Project has a Demo Scene with necessary setup.
- GNU GPL v-3.0 License But you are requested to see the delendency assets licences.
-
I have get ideas from Youtuber 'Dev/GameDevelopment's tutorials
-
Sound Effect from Pixabay
- 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.
- Standard-Assets-Characters I am using Audio files for footstep sound.
- Rifle by Game-Ready Studios
- Unity Simple FPS by me.
- My Behavior Tree by me.
- Traffic-System by me.
- Kiwi coder Behavior Tree by Kiwi Coder.
- I have put all the above packages file and folder inside of this project.
Unity 2020.3.15f2 or higher version.
Copyright © baponkar 2024