Enemy behavior in this example is pretty basic, but still flexible enough to make some fun gameplay.
Enemies will stay where they started until they notice a player. Once they see a player they will chase them and try to attack them until the enemy dies, the player is dead, or has run out of range. Then the enemy will return to the starting point and wait to see a player again or respawn later if possible.
The Combat - Enemy Behavior
script has a lot of options to let you fine tune how an enemy reacts to players. Let's step through the options and see what each one does.
Weapon Template
Target Player Distance
Attack Distance
Allowed Distance From Spawn
Min Distance From Target
The next set of properties control how the enemy moves around the world.
Avoid Distance
Avoid Force
Avoid Duration
Max Drop Height
Unwalkable Tags
Knockback Recovery Seconds
Max Speed
Steering Strength
Gravity Acceleration
Max Vertical
Fall Max Vertical
Run Anim Gait Speed
Respawn On Fall
Kill Height
The following animation properties can only be used on NPC enemies. Voxel object enemies have separate scripts for their animations.
Idle Animation
Running animation
Falling Animation
Knockback Animation
Un Parent Time