How to use Enemies AI
Last updated
Last updated
1- Create a JU Character in Simple Setup
2- Turn on IsAI option and set tag to Enemy(or any other tag that is not "Player")
3- Add a JU Health component and JU Inventory
Your JU Character is now an NPC who can die and also keep items.
To be able to deal damage by punches, make the Hitbox setup:
Adjust the size of the hit boxes the way that best fits your character
The Zombie AI component makes the character walk to a destination or a Waypoint, follow the player and attack him with punches. Your character doesn't necessarily have to be a zombie, you can use this script to make an aggressive NPC for example.
As you can see in the GIF above, it only takes 3 clicks to setup a zombie enemy.
You can also adjust the parameters below to better adapt to what you want
Destination
Destination
Waypoint Path
Waypoint Path
Distance To Finish One Point
Distance to go to next waypoint/path index
Check Nearest Point On Part
Checks the nearest point on the waypoint/path and prevents the AI from going back to a previous Waypoint
On Start Path [Unity Event]
Event called when AI start path
On Following Path [Unity Event]
Event called when AI walk along the path
On Ended [Unity Event]
Event called when AI reaches the end
Target Tags
Filter targets by tags
Field Of View
AI field of view, it is by this sensor that will detect targets
Sensor Layer Mask
Layer Mask of Field of View
Start Running At Distance
Runs when the target is greater than this distance
Attack At Distance
Attack at distance
Aim Up Offset
Target direction height
Look At Target Speed
Look at rotation speed
Min Time To Attack
Min Time To Attack
Max Time To Attack
Max Time To Attack
On Follow Waypoint [Unity Event]
Event called when AI follow a WAYPOINT path
On Follow AI Path [Unity Event]
Event called when AI follow a NAVMESH path
On See Target [Unity Event]
Event called when AI sees a target
On Stop Seeing Target [Unity Event]
Event called when AI stop seeing a target
Patrol AI's parameters are similar to Zombie AI's, so you can use the parameters above to configure Patrol AI in the same way.
The Patrol AI has an extremely similar setup to the Zombie AI, with the difference that it adds a Inventory and an Item Switch Manager. You can add a weapon normally and the AI will start using it, and in the Item Switch Manager you can set the ID of the item it will equip by default.
You can create a Waypoint Path and assign it to the Patrol AI, and you will have a Patrol Enemy: