feat: added stab button

This commit is contained in:
Sara 2024-12-07 17:44:39 +01:00
parent b3cff8240b
commit 656525f76d
20 changed files with 1891 additions and 29 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,4 +1,4 @@
[gd_resource type="AnimationNodeBlendTree" load_steps=44 format=3 uid="uid://c7rxfpfy7vt1b"]
[gd_resource type="AnimationNodeBlendTree" load_steps=46 format=3 uid="uid://c7rxfpfy7vt1b"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_ukhqm"]
animation = &"Aim"
@ -193,10 +193,12 @@ advance_mode = 2
advance_expression = "!get_is_running()"
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_g5qf0"]
xfade_time = 0.1
advance_mode = 2
advance_expression = "get_stab()"
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_27kmb"]
xfade_time = 0.2
switch_mode = 2
advance_mode = 2
advance_expression = "get_is_running()
@ -211,9 +213,20 @@ priority = 2
switch_mode = 2
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_3bu8l"]
xfade_time = 0.1
advance_mode = 2
advance_expression = "get_stab()"
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_cpibo"]
xfade_time = 0.1
switch_mode = 2
advance_mode = 2
advance_expression = "is_walking && walk_speed > 0.0"
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_7smdg"]
"states/Aim Down [aim]/node" = SubResource("AnimationNodeAnimation_ukhqm")
"states/Aim Down [aim]/position" = Vector2(854.525, 226.767)
"states/Aim Down [aim]/position" = Vector2(831.525, 251.767)
"states/Aim [aim] [turn]/node" = SubResource("AnimationNodeAnimation_nhlru")
"states/Aim [aim] [turn]/position" = Vector2(919.525, 94.3447)
states/End/position = Vector2(195.182, 94.3447)
@ -222,16 +235,16 @@ states/End/position = Vector2(195.182, 94.3447)
"states/RESET To Aim/node" = SubResource("AnimationNodeAnimation_ugv1e")
"states/RESET To Aim/position" = Vector2(755.258, 94.3447)
states/Run/node = SubResource("AnimationNodeBlendTree_hmklb")
states/Run/position = Vector2(485.687, 226.767)
states/Run/position = Vector2(361.447, 258.767)
states/Stab/node = SubResource("AnimationNodeAnimation_nur8b")
states/Stab/position = Vector2(361.447, 94.3447)
states/Start/position = Vector2(572.26, 14.954)
"states/Stationary [turn]/node" = SubResource("AnimationNodeBlendTree_p0hk7")
"states/Stationary [turn]/position" = Vector2(572.26, 94.3447)
"states/Walk [turn]/node" = SubResource("AnimationNodeBlendTree_2mbyh")
"states/Walk [turn]/position" = Vector2(666.26, 226.767)
transitions = ["Aim [aim] [turn]", "Aim Down [aim]", SubResource("AnimationNodeStateMachineTransition_4lybd"), "Aim Down [aim]", "Walk [turn]", SubResource("AnimationNodeStateMachineTransition_5aafd"), "Aim [aim] [turn]", "Fire [aim]", SubResource("AnimationNodeStateMachineTransition_8f4gl"), "Fire [aim]", "Aim [aim] [turn]", SubResource("AnimationNodeStateMachineTransition_xnat3"), "Walk [turn]", "Aim [aim] [turn]", SubResource("AnimationNodeStateMachineTransition_12bos"), "Aim Down [aim]", "Stationary [turn]", SubResource("AnimationNodeStateMachineTransition_n0ndr"), "Walk [turn]", "Stationary [turn]", SubResource("AnimationNodeStateMachineTransition_0wc5e"), "Stationary [turn]", "Walk [turn]", SubResource("AnimationNodeStateMachineTransition_4hisb"), "Start", "Stationary [turn]", SubResource("AnimationNodeStateMachineTransition_bmty6"), "Stationary [turn]", "RESET To Aim", SubResource("AnimationNodeStateMachineTransition_kyd6p"), "RESET To Aim", "Aim [aim] [turn]", SubResource("AnimationNodeStateMachineTransition_w5kob"), "Stationary [turn]", "Run", SubResource("AnimationNodeStateMachineTransition_g0i3x"), "Walk [turn]", "Run", SubResource("AnimationNodeStateMachineTransition_ocffv"), "Run", "Stationary [turn]", SubResource("AnimationNodeStateMachineTransition_h0my5"), "Run", "Walk [turn]", SubResource("AnimationNodeStateMachineTransition_nymcr"), "Run", "Stab", SubResource("AnimationNodeStateMachineTransition_g5qf0"), "Stab", "Run", SubResource("AnimationNodeStateMachineTransition_27kmb"), "Stationary [turn]", "Stab", SubResource("AnimationNodeStateMachineTransition_4q0ot"), "Stab", "Stationary [turn]", SubResource("AnimationNodeStateMachineTransition_h6ujc")]
graph_offset = Vector2(-462.578, -0.154999)
"states/Walk [turn]/position" = Vector2(572.26, 258.767)
transitions = ["Aim [aim] [turn]", "Aim Down [aim]", SubResource("AnimationNodeStateMachineTransition_4lybd"), "Aim Down [aim]", "Walk [turn]", SubResource("AnimationNodeStateMachineTransition_5aafd"), "Aim [aim] [turn]", "Fire [aim]", SubResource("AnimationNodeStateMachineTransition_8f4gl"), "Fire [aim]", "Aim [aim] [turn]", SubResource("AnimationNodeStateMachineTransition_xnat3"), "Walk [turn]", "Aim [aim] [turn]", SubResource("AnimationNodeStateMachineTransition_12bos"), "Aim Down [aim]", "Stationary [turn]", SubResource("AnimationNodeStateMachineTransition_n0ndr"), "Walk [turn]", "Stationary [turn]", SubResource("AnimationNodeStateMachineTransition_0wc5e"), "Stationary [turn]", "Walk [turn]", SubResource("AnimationNodeStateMachineTransition_4hisb"), "Start", "Stationary [turn]", SubResource("AnimationNodeStateMachineTransition_bmty6"), "Stationary [turn]", "RESET To Aim", SubResource("AnimationNodeStateMachineTransition_kyd6p"), "RESET To Aim", "Aim [aim] [turn]", SubResource("AnimationNodeStateMachineTransition_w5kob"), "Stationary [turn]", "Run", SubResource("AnimationNodeStateMachineTransition_g0i3x"), "Walk [turn]", "Run", SubResource("AnimationNodeStateMachineTransition_ocffv"), "Run", "Stationary [turn]", SubResource("AnimationNodeStateMachineTransition_h0my5"), "Run", "Walk [turn]", SubResource("AnimationNodeStateMachineTransition_nymcr"), "Run", "Stab", SubResource("AnimationNodeStateMachineTransition_g5qf0"), "Stab", "Run", SubResource("AnimationNodeStateMachineTransition_27kmb"), "Stationary [turn]", "Stab", SubResource("AnimationNodeStateMachineTransition_4q0ot"), "Stab", "Stationary [turn]", SubResource("AnimationNodeStateMachineTransition_h6ujc"), "Walk [turn]", "Stab", SubResource("AnimationNodeStateMachineTransition_3bu8l"), "Stab", "Walk [turn]", SubResource("AnimationNodeStateMachineTransition_cpibo")]
graph_offset = Vector2(-160.578, -16.655)
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_au62i"]
animation = &"Fall_die"
@ -241,7 +254,7 @@ animation = &"Fall_die"
[sub_resource type="AnimationNodeTimeSeek" id="AnimationNodeTimeSeek_p56ym"]
[resource]
graph_offset = Vector2(-363, 102.5)
graph_offset = Vector2(-237, 34.5)
nodes/Actions/node = SubResource("AnimationNodeStateMachine_7smdg")
nodes/Actions/position = Vector2(0, 140)
nodes/Death/node = SubResource("AnimationNodeAnimation_au62i")

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:88259d3e6f9fa520f55792f0e0fd07c804a4eb48ae304de46cf89a656fde6ca2
size 15689272
oid sha256:4adf953423b4b4ac09eff573bcd826ffb8048d41cdcd8c926843b0949a0505a2
size 15774076

File diff suppressed because it is too large Load diff

View file

@ -47,7 +47,7 @@ bones/26/rotation = Quaternion(-0.449756, 0.301541, -0.311322, 0.780943)
bones/27/rotation = Quaternion(-0.122233, -0.135947, -0.565028, 0.804562)
bones/27/scale = Vector3(1, 1, 1)
bones/28/rotation = Quaternion(0.155388, -0.432411, -0.521703, 0.71882)
bones/29/rotation = Quaternion(-0.0486369, 0.0590467, -0.0759536, 0.994173)
bones/29/rotation = Quaternion(-0.0486368, 0.0590466, -0.0759536, 0.994173)
bones/30/rotation = Quaternion(-0.0305179, 0.0130499, 0.0216153, 0.999215)
bones/30/scale = Vector3(1, 1, 1)
bones/31/rotation = Quaternion(-0.518356, -0.00412336, -0.00408935, 0.855145)
@ -59,21 +59,21 @@ bones/34/scale = Vector3(1, 1, 1)
bones/35/rotation = Quaternion(-0.422483, 0.214372, -0.00100308, 0.880654)
bones/36/rotation = Quaternion(-0.345783, -0.0439312, -0.261553, 0.900052)
bones/36/scale = Vector3(1, 1, 1)
bones/37/rotation = Quaternion(-0.0107008, 0.00769689, 0.00365465, 0.999906)
bones/37/rotation = Quaternion(-0.0107009, 0.0076969, 0.00365465, 0.999906)
bones/37/scale = Vector3(1, 1, 1)
bones/38/rotation = Quaternion(-0.389883, 0.108139, -0.120461, 0.906525)
bones/39/rotation = Quaternion(-0.399909, -0.0921328, -0.130163, 0.902575)
bones/40/rotation = Quaternion(-0.0125688, 0.0114118, 0.00134584, 0.999855)
bones/40/rotation = Quaternion(-0.0125688, 0.0114118, 0.00134583, 0.999855)
bones/40/scale = Vector3(1, 1, 1)
bones/41/rotation = Quaternion(-0.0497163, 0.0839878, -0.166226, 0.981246)
bones/42/rotation = Quaternion(-0.0310476, 0.0162325, 0.00151597, 0.999385)
bones/43/rotation = Quaternion(-0.00109126, -0.0104143, 0.0283538, 0.999543)
bones/42/rotation = Quaternion(-0.0310475, 0.0162325, 0.00151601, 0.999385)
bones/43/rotation = Quaternion(-0.00109124, -0.0104143, 0.0283538, 0.999543)
bones/44/position = Vector3(0.16719, 0.195796, -0.0454406)
bones/44/rotation = Quaternion(-0.610992, 0.0971646, 0.14821, 0.771545)
bones/45/rotation = Quaternion(-0.82326, 4.1804e-09, -1.03579e-07, 0.567665)
bones/46/position = Vector3(8.07956e-09, 0.0363644, 0.0392254)
bones/46/rotation = Quaternion(-0.00112372, -6.23921e-08, 6.44731e-09, 0.999999)
bones/48/rotation = Quaternion(0.706312, -2.22455e-08, 6.70979e-08, 0.707901)
bones/48/rotation = Quaternion(0.706312, -2.55434e-08, 6.24918e-08, 0.707901)
bones/48/scale = Vector3(1, 1, 1)
bones/49/position = Vector3(0.0228929, -0.0282939, -0.00824324)
bones/49/rotation = Quaternion(-0.112129, 0.585203, -0.155744, 0.78785)
@ -81,11 +81,13 @@ bones/49/scale = Vector3(1, 1, 1)
bones/50/position = Vector3(-0.0246244, 0.246628, -0.0197923)
bones/50/rotation = Quaternion(0.31578, 0.920316, 0.115311, -0.200014)
bones/50/scale = Vector3(1, 1, 1)
bones/51/position = Vector3(0.0902225, 0.042579, 0.00142519)
bones/51/rotation = Quaternion(0.997309, -0.00549226, 0.0715033, -0.0152251)
bones/51/scale = Vector3(1, 1, 1)
bones/52/rotation = Quaternion(-0.00225666, 0.00306653, -0.000453776, 0.999993)
bones/52/scale = Vector3(1, 1, 1)
bones/53/rotation = Quaternion(0.665461, 0.000165138, -0.00238783, 0.746429)
bones/54/position = Vector3(-0.0902225, 0.042579, 0.00142518)
bones/54/rotation = Quaternion(0.997309, 0.00549227, -0.0715033, -0.0152251)
bones/54/scale = Vector3(1, 1, 1)
bones/55/rotation = Quaternion(-0.00225666, -0.0030665, 0.000453778, 0.999993)
@ -107,11 +109,18 @@ bone_name = "rifle"
bone_idx = 44
[node name="HitscanMuzzle" type="HitscanMuzzle" parent="skeleton_character/Skeleton3D/BoneAttachment3D" index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.37487e-08, 0.5644, 0.0479187)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.84754e-09, 0.268834, 0.0479187)
enabled = false
target_position = Vector3(0, 15, 0)
collision_mask = 3
[node name="BayonetHitscan" type="HitscanMuzzle" parent="skeleton_character/Skeleton3D/BoneAttachment3D" index="1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.91257e-05, -0.0191353, -0.00675189)
enabled = false
target_position = Vector3(0, 1.685, 0)
collision_mask = 3
debug_shape_thickness = 3
[node name="AnimationPlayer" parent="." index="1"]
root_motion_track = NodePath("skeleton_character/Skeleton3D:root")

View file

@ -43,26 +43,36 @@ bones/25/rotation = Quaternion(0.585184, -0.476496, -0.473244, -0.454479)
bones/26/rotation = Quaternion(-0.449756, 0.301541, -0.311322, 0.780943)
bones/27/rotation = Quaternion(-0.122233, -0.135947, -0.565028, 0.804562)
bones/28/rotation = Quaternion(0.155388, -0.432411, -0.521703, 0.71882)
bones/29/rotation = Quaternion(-0.0486368, 0.0590466, -0.0759536, 0.994173)
bones/30/rotation = Quaternion(-0.0305179, 0.0130499, 0.0216153, 0.999215)
bones/31/rotation = Quaternion(-0.518356, -0.00412336, -0.00408935, 0.855145)
bones/32/rotation = Quaternion(-0.290993, 0.0788459, 0.0248015, 0.953148)
bones/33/rotation = Quaternion(-0.419789, -0.067382, -0.039477, 0.904256)
bones/34/rotation = Quaternion(-0.266884, 0.00530696, 0.000658852, 0.963714)
bones/35/rotation = Quaternion(-0.422483, 0.214372, -0.00100308, 0.880654)
bones/36/rotation = Quaternion(-0.345783, -0.0439312, -0.261553, 0.900052)
bones/37/rotation = Quaternion(-0.0107009, 0.0076969, 0.00365465, 0.999906)
bones/38/rotation = Quaternion(-0.389883, 0.108139, -0.120461, 0.906525)
bones/39/rotation = Quaternion(-0.399909, -0.0921328, -0.130163, 0.902575)
bones/40/rotation = Quaternion(-0.0125688, 0.0114118, 0.00134583, 0.999855)
bones/41/rotation = Quaternion(-0.0497163, 0.0839878, -0.166226, 0.981246)
bones/42/rotation = Quaternion(-0.0310475, 0.0162325, 0.00151601, 0.999385)
bones/43/rotation = Quaternion(-0.00109124, -0.0104143, 0.0283538, 0.999543)
bones/44/position = Vector3(0.16719, 0.195796, -0.0454406)
bones/44/rotation = Quaternion(-0.610992, 0.0971646, 0.14821, 0.771545)
bones/45/rotation = Quaternion(-0.82326, 4.1804e-09, -1.03579e-07, 0.567665)
bones/46/position = Vector3(8.07956e-09, 0.0363644, 0.0392254)
bones/46/rotation = Quaternion(-0.00112372, -6.23921e-08, 6.44731e-09, 0.999999)
bones/48/rotation = Quaternion(0.706312, -2.55434e-08, 6.24918e-08, 0.707901)
bones/49/position = Vector3(0.0228929, -0.0282939, -0.00824324)
bones/49/rotation = Quaternion(-0.112129, 0.585203, -0.155744, 0.78785)
bones/50/position = Vector3(-0.0246244, 0.246628, -0.0197923)
bones/50/rotation = Quaternion(0.31578, 0.920316, 0.115311, -0.200014)
bones/51/position = Vector3(0.0902225, 0.042579, 0.00142519)
bones/51/rotation = Quaternion(0.997309, -0.00549226, 0.0715033, -0.0152251)
bones/52/rotation = Quaternion(-0.00225666, 0.00306653, -0.000453776, 0.999993)
bones/53/rotation = Quaternion(0.665461, 0.000165138, -0.00238783, 0.746429)
bones/54/position = Vector3(-0.0902225, 0.042579, 0.00142518)
bones/54/rotation = Quaternion(0.997309, 0.00549227, -0.0715033, -0.0152251)
bones/55/rotation = Quaternion(-0.00225666, -0.0030665, 0.000453778, 0.999993)
bones/56/rotation = Quaternion(0.665461, -0.000165001, 0.00238774, 0.746429)

View file

@ -47,26 +47,36 @@ bones/25/rotation = Quaternion(0.585184, -0.476496, -0.473244, -0.454479)
bones/26/rotation = Quaternion(-0.449756, 0.301541, -0.311322, 0.780943)
bones/27/rotation = Quaternion(-0.122233, -0.135947, -0.565028, 0.804562)
bones/28/rotation = Quaternion(0.155388, -0.432411, -0.521703, 0.71882)
bones/29/rotation = Quaternion(-0.0486368, 0.0590466, -0.0759536, 0.994173)
bones/30/rotation = Quaternion(-0.0305179, 0.0130499, 0.0216153, 0.999215)
bones/31/rotation = Quaternion(-0.518356, -0.00412336, -0.00408935, 0.855145)
bones/32/rotation = Quaternion(-0.290993, 0.0788459, 0.0248015, 0.953148)
bones/33/rotation = Quaternion(-0.419789, -0.067382, -0.039477, 0.904256)
bones/34/rotation = Quaternion(-0.266884, 0.00530696, 0.000658852, 0.963714)
bones/35/rotation = Quaternion(-0.422483, 0.214372, -0.00100308, 0.880654)
bones/36/rotation = Quaternion(-0.345783, -0.0439312, -0.261553, 0.900052)
bones/37/rotation = Quaternion(-0.0107009, 0.0076969, 0.00365465, 0.999906)
bones/38/rotation = Quaternion(-0.389883, 0.108139, -0.120461, 0.906525)
bones/39/rotation = Quaternion(-0.399909, -0.0921328, -0.130163, 0.902575)
bones/40/rotation = Quaternion(-0.0125688, 0.0114118, 0.00134583, 0.999855)
bones/41/rotation = Quaternion(-0.0497163, 0.0839878, -0.166226, 0.981246)
bones/42/rotation = Quaternion(-0.0310475, 0.0162325, 0.00151601, 0.999385)
bones/43/rotation = Quaternion(-0.00109124, -0.0104143, 0.0283538, 0.999543)
bones/44/position = Vector3(0.16719, 0.195796, -0.0454406)
bones/44/rotation = Quaternion(-0.610992, 0.0971646, 0.14821, 0.771545)
bones/45/rotation = Quaternion(-0.82326, 4.1804e-09, -1.03579e-07, 0.567665)
bones/46/position = Vector3(8.07956e-09, 0.0363644, 0.0392254)
bones/46/rotation = Quaternion(-0.00112372, -6.23921e-08, 6.44731e-09, 0.999999)
bones/48/rotation = Quaternion(0.706312, -2.55434e-08, 6.24918e-08, 0.707901)
bones/49/position = Vector3(0.0228929, -0.0282939, -0.00824324)
bones/49/rotation = Quaternion(-0.112129, 0.585203, -0.155744, 0.78785)
bones/50/position = Vector3(-0.0246244, 0.246628, -0.0197923)
bones/50/rotation = Quaternion(0.31578, 0.920316, 0.115311, -0.200014)
bones/51/position = Vector3(0.0902225, 0.042579, 0.00142519)
bones/51/rotation = Quaternion(0.997309, -0.00549226, 0.0715033, -0.0152251)
bones/52/rotation = Quaternion(-0.00225666, 0.00306653, -0.000453776, 0.999993)
bones/53/rotation = Quaternion(0.665461, 0.000165138, -0.00238783, 0.746429)
bones/54/position = Vector3(-0.0902225, 0.042579, 0.00142518)
bones/54/rotation = Quaternion(0.997309, 0.00549227, -0.0715033, -0.0152251)
bones/55/rotation = Quaternion(-0.00225666, -0.0030665, 0.000453778, 0.999993)
bones/56/rotation = Quaternion(0.665461, -0.000165001, 0.00238774, 0.746429)

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8f82d3165663c49f4662cdc8d24b802e58bab038145b621308a1555e88110f75
size 3189752
oid sha256:d6cffb68fe33a0bd720f818f84669f1bd26688ca02f8f7027d9f7cc1c8b9c487
size 3184792

Binary file not shown.

View file

@ -85,8 +85,10 @@ void Player::_on_dir_vertical(gd::Ref<gd::InputEvent>, float value) {
}
void Player::_on_fire(gd::Ref<gd::InputEvent> event, float) {
if(event->is_pressed())
if(event->is_pressed()) {
this->anim_tree->set_fire_weapon();
this->anim_tree->set_stab();
}
}
void Player::_on_run(gd::Ref<gd::InputEvent> event, float) {

View file

@ -10,6 +10,7 @@ void PlayerAnimTree::_bind_methods() {
GDFUNCTION(get_is_running);
GDPROPERTY(aim_weapon, gd::Variant::BOOL);
GDFUNCTION(get_fire_weapon);
GDFUNCTION(get_stab);
}
void PlayerAnimTree::_ready() {
@ -22,6 +23,7 @@ void PlayerAnimTree::_process(double delta) {
return;
// update timers
this->fire_weapon -= delta;
this->stab -= delta;
this->running_time -= delta;
// increase death counter
if(this->is_dead && this->death_blend < 1.f) {
@ -29,16 +31,18 @@ void PlayerAnimTree::_process(double delta) {
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.));
if(this->match_tags(Tags::Turn)) {
this->turn_speed = gd::Math::move_toward(this->turn_speed, this->target_turn_speed, float(delta * 20.));
this->commit_turn_speed();
}
// rotational root motion
this->parent_3d->set_quaternion(this->get_root_motion_rotation_accumulator());
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) {
this->target_turn_speed = value;
this->target_turn_speed = gd::Math::clamp(value, -1.f, 1.f);
}
float PlayerAnimTree::get_target_turn_speed() const {
@ -79,12 +83,22 @@ bool PlayerAnimTree::get_aim_weapon() const {
}
void PlayerAnimTree::set_fire_weapon() {
this->fire_weapon = this->FIRE_PARAM_DECAY;
this->fire_weapon = this->BUTTON_PARAM_DECAY;
}
bool PlayerAnimTree::get_fire_weapon() {
bool const is_set = this->fire_weapon > 0.f;
this->fire_weapon = 0.f;
bool const is_set{this->fire_weapon > 0.0};
this->fire_weapon = 0.0;
return is_set;
}
void PlayerAnimTree::set_stab() {
this->stab = this->BUTTON_PARAM_DECAY;
}
bool PlayerAnimTree::get_stab() {
bool const is_set{this->fire_weapon > 0.0};
this->stab = 0.0;
return is_set;
}
@ -103,13 +117,15 @@ void PlayerAnimTree::update_tags(gd::StringName const &anim) {
this->current_tags = Tags::None;
if(anim.contains("[turn]"))
this->current_tags = Tags(this->current_tags | Tags::Turn);
else
this->turn_speed = 0.f;
if(anim.contains("[aim]"))
this->current_tags = Tags(this->current_tags | Tags::Aim);
}
}
void PlayerAnimTree::commit_turn_speed() {
this->set("parameters/Actions/Stationary [turn]/Turn/blend_position", this->turn_speed);
this->set("parameters/Actions/Stationary [turn]/Turn/blend_position", gd::Math::abs(this->turn_speed)*this->turn_speed);
}
void PlayerAnimTree::commit_walk_speed() {

View file

@ -32,15 +32,17 @@ public:
bool get_aim_weapon() const;
void set_fire_weapon();
bool get_fire_weapon();
bool match_tags(Tags tags) const;
void set_stab();
bool get_stab();
void death_animation();
bool match_tags(Tags tags) const;
private:
void update_tags(gd::StringName const &anim);
void commit_turn_speed();
void commit_walk_speed();
private:
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 BUTTON_PARAM_DECAY{0.1}; //!< 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.
gd::Node3D *parent_3d{nullptr}; //!< immediate parent as Node3D, rotational root motion is applied to this.
@ -51,7 +53,8 @@ private:
float walk_speed{0.f}; //!< blend amount between RESET/Rest animation and walk animation in walk state.
double running_time{0.0}; //!< time in seconds to keep running for.
bool aim_weapon{false}; //!< set to true to play the aim animation.
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.
double fire_weapon{0.0}; //!< play fire animation if this is > 0. Set to BUTTON_PARAM_DECAY when set_fire_weapon is called. Decays by 'delta' every frame.
double stab{0.0}; //!< player stab animation if this is > 0. Set to BUTTON_PARAM_DECAY when set_stab is called. Decays by 'delta' every frame.
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}; //!< set to true to play death animation and tick up death_blend.
Tags current_tags{Tags::None}; //!< tags (like [turn]) on the current action state.