Add a comment explaining a piece of code and tweak the headbob animation
This commit is contained in:
@ -238,6 +238,9 @@ func headbob_animation(moving):
|
|||||||
HEADBOB_ANIMATION.speed_scale = (current_speed / base_speed) * 1.75
|
HEADBOB_ANIMATION.speed_scale = (current_speed / base_speed) * 1.75
|
||||||
if !was_playing:
|
if !was_playing:
|
||||||
HEADBOB_ANIMATION.seek(float(randi() % 2)) # Randomize the initial headbob direction
|
HEADBOB_ANIMATION.seek(float(randi() % 2)) # Randomize the initial headbob direction
|
||||||
|
# Let me explain that piece of code because it looks like it does the opposite of what it actually does.
|
||||||
|
# The headbob animation has two starting positions. One is at 0 and the other is at 1.
|
||||||
|
# randi() % 2 returns either 0 or 1, and so the animation randomly starts at one of the starting positions.
|
||||||
|
|
||||||
else:
|
else:
|
||||||
HEADBOB_ANIMATION.play("RESET", 0.25)
|
HEADBOB_ANIMATION.play("RESET", 0.25)
|
||||||
|
@ -14,6 +14,33 @@ material = SubResource("StandardMaterial3D_kp17n")
|
|||||||
|
|
||||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_uy03j"]
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_uy03j"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_pqev3"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Mesh:position")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector3(0, 1, 0)]
|
||||||
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath("Head:position")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector3(0, 1.5, 0)]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_5ec5e"]
|
[sub_resource type="Animation" id="Animation_5ec5e"]
|
||||||
resource_name = "crouch"
|
resource_name = "crouch"
|
||||||
length = 0.2
|
length = 0.2
|
||||||
@ -78,33 +105,6 @@ tracks/4/keys = {
|
|||||||
"values": [Vector3(0, 1.5, 0), Vector3(0, 1.12508, 0)]
|
"values": [Vector3(0, 1.5, 0), Vector3(0, 1.12508, 0)]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_pqev3"]
|
|
||||||
length = 0.001
|
|
||||||
tracks/0/type = "value"
|
|
||||||
tracks/0/imported = false
|
|
||||||
tracks/0/enabled = true
|
|
||||||
tracks/0/path = NodePath("Mesh:position")
|
|
||||||
tracks/0/interp = 1
|
|
||||||
tracks/0/loop_wrap = true
|
|
||||||
tracks/0/keys = {
|
|
||||||
"times": PackedFloat32Array(0),
|
|
||||||
"transitions": PackedFloat32Array(1),
|
|
||||||
"update": 0,
|
|
||||||
"values": [Vector3(0, 1, 0)]
|
|
||||||
}
|
|
||||||
tracks/1/type = "value"
|
|
||||||
tracks/1/imported = false
|
|
||||||
tracks/1/enabled = true
|
|
||||||
tracks/1/path = NodePath("Head:position")
|
|
||||||
tracks/1/interp = 1
|
|
||||||
tracks/1/loop_wrap = true
|
|
||||||
tracks/1/keys = {
|
|
||||||
"times": PackedFloat32Array(0),
|
|
||||||
"transitions": PackedFloat32Array(1),
|
|
||||||
"update": 0,
|
|
||||||
"values": [Vector3(0, 1.5, 0)]
|
|
||||||
}
|
|
||||||
|
|
||||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_5e5t5"]
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_5e5t5"]
|
||||||
_data = {
|
_data = {
|
||||||
"RESET": SubResource("Animation_pqev3"),
|
"RESET": SubResource("Animation_pqev3"),
|
||||||
@ -172,7 +172,7 @@ tracks/1/interp = 1
|
|||||||
tracks/1/loop_wrap = true
|
tracks/1/loop_wrap = true
|
||||||
tracks/1/keys = {
|
tracks/1/keys = {
|
||||||
"handle_modes": PackedInt32Array(0, 0, 0, 0, 0),
|
"handle_modes": PackedInt32Array(0, 0, 0, 0, 0),
|
||||||
"points": PackedFloat32Array(-0.05, -0.25, 0, 0.2, 0.005, 0, -0.25, 0, 0.25, 0, -0.05, -0.2, 0.005, 0.2, 0.005, 0, -0.25, 0, 0.25, 0, -0.05, -0.2, 0.005, 0.25, 0),
|
"points": PackedFloat32Array(-0.05, -0.25, 0, 0.2, 0.005, 0, -0.2, 0.000186046, 0.2, 0.000186046, -0.05, -0.2, 0.005, 0.2, 0.005, 0, -0.2, 0, 0.2, 0, -0.05, -0.2, 0.005, 0.25, 0),
|
||||||
"times": PackedFloat32Array(0, 0.5, 1, 1.5, 2)
|
"times": PackedFloat32Array(0, 0.5, 1, 1.5, 2)
|
||||||
}
|
}
|
||||||
tracks/2/type = "bezier"
|
tracks/2/type = "bezier"
|
||||||
|
Reference in New Issue
Block a user