Player

Node representing the playable character.

Inherits : Entity

Description

This Node represent the playable character.

It’s an Entity, and simply modify some general behavior into more specific ones :

  • Change a few characteristics
  • Firing projectile is bow-specific

Methods description

_ready()

Method starting animations, adding the Node to the players group, and changing a few Entity characteristics.

_process()

Arguments

delta
Delta (see Godot documentation for more details).

This method is executed every frame and do several things :

  • If the player don’t have a target anymore, select a new one.
  • Get the input from user and set a new destination accordingly, as well as animation. It does not move the player, simply set the new destination.
  • Emit right signal depending if the player is running or not.

Emitted signals

running
This signal is emitted when the player is moving.
immobile
This signal is emitted when the player is not moving.

_physics_process(delta)

Arguments

delta
Delta (see Godot documentation for more details).

This method takes care of the physics engine processing : it moves the player according to :

  • The base velocity of the player (computed from the destination, set in _process())
  • The knockback velocity, if any.

_on_HealthBar_dead()

Free itself upon receiving the dead signal.

Receives signals

dead
This signal is emitted when the healthbar reach 0.

fire(projectile, atk_speed)

Arguments

projectile
Instancied projectile to fire.
atk_speed
Attack speed to use to fire.

Overwrite the parent method for firing the projectile. It delegate the actual firing to the Bow.

This method does nothing if no target is selected.

interrupt_shooting()

This method interrupt the animation of Bow.