Entity¶
Abstract Node for common behavior between all entities.
Inherits : KinematicBody2D
Properties¶
Methods¶
Constants¶
- SELECT_CLOSEST = “closest”
- One of existing targetting method.This one will choose the closest ennemy to the player.
Signals¶
- running
- Signal emitted when the entity is moving.This signal should be emitted from the
_physics_process()
function of the child class (not handled in this class).Emitted by : Player._process() Received by : Shooter._on_running_timeout()
- immobile
- Signal emitted when the entity is not moving.This signal should be emitted from the
_physics_process()
function of the child class (not handled in this class).Emitted by : Player._process() Received by : Shooter._on_immobile_timeout()
Description¶
This is an Abstract Node, meaning it’s just a script (there is no scene associated to this script).
It is used to define common behavior between all entities to avoid code duplication.
Common behaviors handled by this Node are mainly :
- Common properties and associated methods
- Knockback
- Fire projectile
- Hit by projectile
Properties description¶
knockbacker_pos
¶
Type | Vector2 |
Default | null |
knockbacker_pow
¶
Type | int |
knockback_frame
¶
Type | int |
Default | 0 |
knockback_ratios
in order to create a smooth knockback animation.knockback_ratios
¶
Type | array of float |
Default | [9, 8, 6.5, 4.5, 2] |
damage
¶
Type | int |
Default | 10 |
Knockback damages inflicted by this entity to other knockbacked entities.
destination
¶
Type | Vector2 |
Default | null |
(0, 0)
and the destination is set to (1, 0)
, entity will move to the right.Methods description¶
set_destination(dest=null)
¶
Arguments
|
null
is given.reset_destination()
¶
Reset the current destination to null
.
get_base_velocity()
¶
Return Vector2 |
destination
using speed
.knockback_from(collider)
¶
Arguments
|
knockbacker_pos
and knockbacker_pow
.apply_knockback()
.apply_knockback(velocity)
¶
Return Vector2 |
Arguments
|
Compute the knockback velocity, based on :
knockbacker_pos
&knockbacker_pow
- current position
- given velocity
knockback_ratios
&knockback_frame
is_targetting()
¶
Return bool |
In order to know if the entity is targetting something or not, this method should be called.
select_target(group_name, selection_method="closest")
¶
Return float |
Arguments
|
null
.fire(projectile, atk_speed)
¶
Arguments
|
This method is used as a general method for firing a projectile. For specific behaviors, please refer to each Node.
This method does nothing if no target is selected.
interrupt_shooting()
¶
fire()
.hit_by(projectile)
¶
Arguments
|
This method does 2 things :
- Update the health bar of the entity based on the damage of the projectile.
- Knockback the entity from the projectile.