Enemy Behaviour

Checked with version: 2017.3

-

Difficulty: Beginner

The Enemy Behaviour Component is applied to Chomper and Spitter, our two enemies in the game. Find these enemies in the project window in Prefabs > Enemies.

Both enemies use the same component, they just use different settings.

  • Sprite Faces Left: Check this box if the Sprite should face left.

  • Movement

    • Speed: The speed of the enemy.

    • Gravity: How fast it falls.

  • References

    • Projectile Prefab: The Prefab of the projectile the enemy is to fire (only for projectile enemy).
  • Scanning Settings

    • View Direction: The direction in which the enemy can detect the player. This is depicted with a green circle in the Scene View

    • View FOV: The Field of View the enemy has. This is depicted with a green circle in the Scene View

    • View Distance: How far away the enemy can see the player. This is depicted with a green circle in the Scene View

    • Time Before Target Lost: The amount of time before the enemy will stop chasing or searching the player once the player is out of range.

  • Melee Attack Data Melee attack information, this only applies to Melee enemies like Chomper.

    • Melee Range: The distance away from itself the enemy can hit the player.

    • Melee Damager: The Damager Script on the enemy. See Damage System for more information.

    • Contact Damager: The Contact Damager Script on the enemy, this script causes damage by touching the enemy.

    • Attack Dash: Enables or disables a dash forward when the enemy attacks.

    • Attack Force: The force applied to the Player when they’re attacked. This is what pushes the player back after being attacked.

  • Ranged Attack Data Ranged attack information. This only applies to for ranged enemies like Spitter.

    • Shooting Origin: The position the projectile is shot from.

    • Shoot Angle: The angle at which the projectile is shot from the origin.

    • Shoot Force: The force applied to the projectile.

    • Fire Rate: How fast the projectiles are shot.

  • Audio

    • Shooting Audio: The RandomAudioPlayer used when a shot is fired.

    • Melee Attack Audio: The RandomAudioPlayer used when a Melee attack occurs.

    • Die Audio: The RandomAudioPlayer used when the enemy dies.

    • Foot Step Audio: The RandomAudioPlayer used for the enemy’s footsteps.

  • Misc

    • Flickering Duration: If the enemy’s health is more than 1, when it is hit, it flickers to indicate a hit. This value is the duration of time the flicker lasts.

Related tutorials