Eye of the Nile Docs
Everything you need to know to get started!
Loading...
Searching...
No Matches
MeleeEntityController Class Reference

Detailed Description

Functionality for basic entities with a melee attack. Inherits from BaseEntityController.

Documentation updated 8/26/2024

Author
Stephen Nuttall

Public Attributes

float attackRange = 0.5f
 The distance from the attack point that enemies will be hit (size of attack point).
 
float knockback = 75f
 The strength of the knockback that the attack will apply.
 
bool knockbackEnabled = true
 If true, the melee attack will apply knockback to the attacked object.
 

Protected Member Functions

override void ActivateAttack ()
 Scan the attack range for enemies, and apply damage and knockback (if enabled)
 
override void TriggerAttack ()
 Trigger attacking animation.
 
- Protected Member Functions inherited from BaseEntityController
void ActivateAttack ()
 Triggered by an event in the attack animation (or you can override TriggerAttack() if there is not attack animation). This function muse be overridden by any inheriting class.
 
virtual void PatrolState ()
 When the entity hasn't detected any enemies...
 
virtual void ChaseState ()
 If the entity has detected an enemy...
 
virtual void CloseAttackState ()
 If the entity is close enough to an enemy to attack...
 

Additional Inherited Members

- Public Member Functions inherited from BaseEntityController
void ChangeSpeed (float speedChange)
 Speeds up or slows down the entity's movement speed. A negative value for speedChange will slow down the entity.
 
void ChangeSpeed (float speedChange, float duration)
 Temporarily speeds up or slows down the entity's movement speed. A negative value for speedChange will slow down the entity.
 
void DestroyOnDeath ()
 Can be optionaly run by ObjectHealth.onDeath.
 
- Protected Attributes inherited from BaseEntityController
ObjectHealth objectHealth
 Reference to the object responsible for managing the player's health.
 
Transform attackPoint
 Reference to the entity's attack point. It's a point in space that's a child of the entity, existing some distance in front of it. Projectiles spawn from the attack point, and melee attacks scan for enemies to damage from a certain radius around it.
 
int attackDamage = 30
 Amount of damage the entity's attack will deal.
 
float attackCooldown = 0.8f
 The amount of time between attacks.
 
float cooldownEndTime = 0f
 Amount of time until cooldown is over. Set to the current time + attackCooldown when the attack is triggered.
 
LayerMask enemyLayers
 Objects on these layers will be considered an enemy of this entity, and if detected, this entity will seek to attack. An object can be assigned to a layer in the Unity Editor from a drop down menu in the top right.
 
PatrolZone patrolZone
 A patrol zone is an object that has two points the entity will walk between if it does not detect an enemy.
 
float horizontalDirection = 0f
 Horizontal direction the entity is traveling in.
 
float detectionRange = 6f
 How far away the entity will detect an enemy from and start chasing.
 
float activateAttackRange = 3f
 How close the entity must be to an enemy to attack it.
 
float entityCenter = 1.4f
 
bool hostileDetected = false
 True if the entity has detected an enemy.
 
bool hostileInCloseRange = false
 True if the entity is close enough to an enemy to attack it.
 
Rigidbody2D rb
 Reference to the entity's rigidbody.
 
float moveVelocity = 6.0f
 How fast the entity should move.
 
float speedModifier = 0f
 The precent of moveVelocity the entity should move at. Used for slowing the entity down.
 
float linearDrag = 1.0f
 Amount of drag to apply to the rigidbody.
 
float groundedRaycastLength = 1.8f
 
GroundDetector groundDetector
 Reference to the entity's GroundDetector.
 
bool groundNeeded = true
 Can be set to false to let the entity walk even when it is not on the ground.
 
bool canWalk = true
 Used for disabling entity movement.
 
Animator animator
 Reference to the entity's animator.
 
- Properties inherited from BaseEntityController
EntityState EState = EntityState.Patrol [get, protected set]
 Current state the entity is in.
 

Member Function Documentation

◆ ActivateAttack()

override void MeleeEntityController.ActivateAttack ( )
protected

Scan the attack range for enemies, and apply damage and knockback (if enabled)

◆ TriggerAttack()

override void MeleeEntityController.TriggerAttack ( )
protectedvirtual

Trigger attacking animation.

Reimplemented from BaseEntityController.

Member Data Documentation

◆ attackRange

float MeleeEntityController.attackRange = 0.5f

The distance from the attack point that enemies will be hit (size of attack point).

◆ knockback

float MeleeEntityController.knockback = 75f

The strength of the knockback that the attack will apply.

◆ knockbackEnabled

bool MeleeEntityController.knockbackEnabled = true

If true, the melee attack will apply knockback to the attacked object.


The documentation for this class was generated from the following file: