Enemy Properties

This article lists the properties of an Enemy.

Enemy Health

Enemy health has the following properties:

Health Enemies have a starting health which you can adjust using the slider or text field.
Invulnerability Time How long should the enemy be invulnerable to damage after being hit (measured in seconds).

 

Enemy Interactions

These settings control general interactions between the Enemy and other components such as Enemy Movements and Platforms.

Continue Movement On Fall If false the character will set the AnimationState to falling when the character falls and no Movement will control the character. If true movement will still be able to control the character in the falling state.
Switch Colliders On Direction Change If true the left and right colliders will be flipped when the character changes direction. This is primarily for asymmetric characters.
Start Facing Direction To easily align with your sprites you can set the initial facing direction.
 Enemy Interacts With Platforms  If true this Enemy will be able to trigger and parent to platforms much like a Character. Note that not all platform types will work with enemies.

 

Enemy Collisions

Enemies use a much simplified version of the characters geometry collision system. Remember that not all enemies need geometry collisions, for example if an enemy simple walks back and forth on solid indestructible ground then there's no reason for it to check the ground beneath it.

To set up enemy collisions use the following properties:

Geometry Layer Mask A list of layers that the enemy collides with.
Can Character Fall If true the character will need feet colliders and will fall if its feet colliders aren't touching something.
Terminal Velocity The maximum speed the character can fall at (negative number).
Grounded Lookahead How far above the ground can the enemy be and still be considered grounded. For enemies you can often leave this at 0, but if your enemy needs to snap to ground on slopes or be able to stand on vertically moving platforms then this will need to be increased.
Use Character Gravity If true then the gravity applied to the enemy will be the same as the gravity applied to the character. The way the character is found is quite simple (FindObjectOfType) so this may not be suitable for multiplayer games.
Custom Gravity If not using character gravity set the custom gravity here (usually a negative number).
Side Collisions Does the enemy have side colliders. If not they will be able to walk through geometry that gets in their way.
Switch on Side Hit If the character runs in to something should it turn around? Make sure your EnemyMovement supports this (most of the out-of-the-box EnemyMovements do).

Once your properties are configured you can use the Edit Feet and Edit Sides buttons to adjust Enemy colliders. Doing this will bring up movable handles in the in the Scene View which allow you to adjust the location of the feet and side colliders respectively.


Help! I Need more Colliders


To minimise performance impact of Enemies they perform a limited number of collisions (2 feet, 2 side, no head colliders).

Note: Side collisions are skipped if the enemy is moving in the opposite direction to the colliders direction. Generally this is okay, but if you have fast moving platforms that can push your Enemy you may need to customise.

If you need more collisions you can extend the Enemy class or use a Character class for your Enemy. See also Enemy Design.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk