feat: comment pass on player animation tree class
parent
ff0199a342
commit
c65a059ffd
|
@ -20,17 +20,21 @@ void PlayerAnimTree::_ready() {
|
||||||
void PlayerAnimTree::_process(double delta) {
|
void PlayerAnimTree::_process(double delta) {
|
||||||
if(gd::Engine::get_singleton()->is_editor_hint())
|
if(gd::Engine::get_singleton()->is_editor_hint())
|
||||||
return;
|
return;
|
||||||
this->turn_speed = gd::Math::move_toward(this->turn_speed, this->target_turn_speed, float(delta * 30.));
|
// update timers
|
||||||
this->commit_turn_speed();
|
|
||||||
this->update_tags(this->fsm->get_current_node());
|
|
||||||
this->fire_weapon -= delta;
|
this->fire_weapon -= delta;
|
||||||
this->running_time -= delta;
|
this->running_time -= delta;
|
||||||
|
// increase death counter
|
||||||
if(this->is_dead && this->death_blend < 1.f) {
|
if(this->is_dead && this->death_blend < 1.f) {
|
||||||
this->death_blend = gd::Math::min(this->death_blend + float(delta * this->DEATH_BLEND_SPEED), 1.f);
|
this->death_blend = gd::Math::min(this->death_blend + float(delta * this->DEATH_BLEND_SPEED), 1.f);
|
||||||
this->set("parameters/DeathBlend/blend_amount", this->death_blend);
|
this->set("parameters/DeathBlend/blend_amount", this->death_blend);
|
||||||
}
|
}
|
||||||
|
// turn speed smoothing
|
||||||
|
this->turn_speed = gd::Math::move_toward(this->turn_speed, this->target_turn_speed, float(delta * 30.));
|
||||||
|
// rotational root motion
|
||||||
this->parent_3d->set_quaternion(this->get_root_motion_rotation_accumulator());
|
this->parent_3d->set_quaternion(this->get_root_motion_rotation_accumulator());
|
||||||
this->parent_3d->rotate_y(M_PIf);
|
this->parent_3d->rotate_y(M_PIf);
|
||||||
|
this->commit_turn_speed();
|
||||||
|
this->update_tags(this->fsm->get_current_node());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerAnimTree::set_target_turn_speed(float value) {
|
void PlayerAnimTree::set_target_turn_speed(float value) {
|
||||||
|
|
|
@ -12,9 +12,9 @@ class PlayerAnimTree : public gd::AnimationTree {
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
public:
|
public:
|
||||||
enum Tags : unsigned {
|
enum Tags : unsigned {
|
||||||
None = 0x0,
|
None = 0x0, //!< don't apply any state-specific logic
|
||||||
Turn = 0x1,
|
Turn = 0x1, //!< allow turning of the character
|
||||||
Aim = 0x2
|
Aim = 0x2 //!< (player only) slow down camera movement when aiming
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
virtual void _ready() override;
|
virtual void _ready() override;
|
||||||
|
@ -39,23 +39,23 @@ private:
|
||||||
void commit_turn_speed();
|
void commit_turn_speed();
|
||||||
void commit_walk_speed();
|
void commit_walk_speed();
|
||||||
private:
|
private:
|
||||||
double const DEATH_BLEND_SPEED{1. / 0.3}; //!< multiplier for delta_time when blending from state machine to death animation
|
double const DEATH_BLEND_SPEED{1. / 0.3}; //!< multiplier for delta_time when blending from state machine to death animation.
|
||||||
double const FIRE_PARAM_DECAY{0.5}; //!< how many seconds it takes for a fire input to become invalid
|
double const FIRE_PARAM_DECAY{0.5}; //!< how many seconds it takes for a fire input to become invalid.
|
||||||
double const RUN_PARAM_DECAY{0.25}; //!< how many seconds to run every time set_is_running is called
|
double const RUN_PARAM_DECAY{0.25}; //!< how many seconds to run every time set_is_running is called.
|
||||||
|
|
||||||
gd::Node3D *parent_3d{nullptr};
|
gd::Node3D *parent_3d{nullptr}; //!< immediate parent as Node3D, rotational root motion is applied to this.
|
||||||
gd::Ref<gd::AnimationNodeStateMachinePlayback> fsm;
|
gd::Ref<gd::AnimationNodeStateMachinePlayback> fsm{}; //!< actions state machine from animation blend tree.
|
||||||
float turn_speed{0.f};
|
float turn_speed{0.f}; //!< blend position of turn animation (-1 to 1). Moved towards target_turn_speed every frame.
|
||||||
float target_turn_speed{0.f};
|
float target_turn_speed{0.f}; //!< target blend position of turn animation.
|
||||||
bool is_walking{false};
|
bool is_walking{false}; //!< set to true if the walk animation should be playing.
|
||||||
float walk_speed{0.f};
|
float walk_speed{0.f}; //!< blend amount between RESET/Rest animation and walk animation in walk state.
|
||||||
double running_time{0.0};
|
double running_time{0.0}; //!< time in seconds to keep running for.
|
||||||
bool aim_weapon{false};
|
bool aim_weapon{false}; //!< set to true to play the aim animation.
|
||||||
double fire_weapon{0.0};
|
double fire_weapon{0.0}; //!< play fire animation if this is > 0. Set to FIRE_PARAM_DECAY when set_fire_weapon is called. Decays by 'delta' every frame.
|
||||||
float death_blend{0.f};
|
float death_blend{0.f}; //!< current blend level of death animation. Quickly moved towards 1.0 when is_dead is set.
|
||||||
bool is_dead{false};
|
bool is_dead{false}; //!< set to true to play death animation and tick up death_blend.
|
||||||
Tags current_tags{Tags::None};
|
Tags current_tags{Tags::None}; //!< tags (like [turn]) on the current action state.
|
||||||
gd::StringName last_known_anim{};
|
gd::StringName last_known_anim{}; //!< last known animation state in action state machine.
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !PLAYER_ANIM_HPP
|
#endif // !PLAYER_ANIM_HPP
|
||||||
|
|
Loading…
Reference in New Issue