Implement jump/fall animations
This commit is contained in:
@@ -40,7 +40,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.297908, 0)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.144889, 0)
|
||||
|
||||
[node name="HeadBoneAttachment3D" type="BoneAttachment3D" parent="Neck"]
|
||||
transform = Transform3D(0.999959, -0.00908396, 8.09411e-05, 0.00908177, 0.999849, 0.0147945, -0.000215322, -0.0147932, 0.99989, -0.0013746, -0.0538376, 0.0128872)
|
||||
transform = Transform3D(0.999974, -0.00719406, 8.09973e-08, 0.00719406, 0.999974, -1.33776e-07, -8.00328e-08, 1.34355e-07, 1, 0.00301405, -0.0458933, 0.00284567)
|
||||
bone_name = "HeadBone.002"
|
||||
bone_idx = 8
|
||||
use_external_skeleton = true
|
||||
@@ -62,27 +62,6 @@ replication_config = SubResource("SceneReplicationConfig_ulp21")
|
||||
|
||||
[node name="Mesh" parent="." instance=ExtResource("2_3c3w1")]
|
||||
|
||||
[node name="Skeleton3D" parent="Mesh/Armature" index="0"]
|
||||
bones/0/position = Vector3(4.26202e-05, -0.32356, -0.000609326)
|
||||
bones/0/rotation = Quaternion(0.0203988, 0.00010767, 0.00391705, 0.999784)
|
||||
bones/1/rotation = Quaternion(-0.0248584, -6.36843e-12, 9.57895e-11, 0.999691)
|
||||
bones/2/rotation = Quaternion(0.0914404, 0.0920409, 0.97708, 0.168765)
|
||||
bones/3/rotation = Quaternion(0.0520362, 2.17449e-05, 0.221285, 0.97382)
|
||||
bones/4/rotation = Quaternion(0.0161356, 0.000328901, 0.0898733, 0.995822)
|
||||
bones/5/rotation = Quaternion(-0.112112, 0.113354, -0.962453, 0.219697)
|
||||
bones/6/rotation = Quaternion(-0.0678804, 0.0011636, -0.221119, 0.972881)
|
||||
bones/7/rotation = Quaternion(-0.0215328, 0.000574495, -0.0928375, 0.995448)
|
||||
bones/8/rotation = Quaternion(-0.00293645, 7.25297e-05, 0.000623416, 0.999996)
|
||||
bones/9/rotation = Quaternion(0.0803629, -0.105083, 0.98951, -0.0580557)
|
||||
bones/10/rotation = Quaternion(0.00201719, 0.0658942, -8.48654e-05, 0.997825)
|
||||
bones/11/rotation = Quaternion(0.987418, -0.00859132, 0.00926525, 0.157626)
|
||||
bones/12/rotation = Quaternion(0.193335, -0.014129, -7.2887e-05, 0.981031)
|
||||
bones/13/position = Vector3(-0.0477975, -0.700956, -0.0941017)
|
||||
bones/14/position = Vector3(0.0828021, -0.67129, 0.039274)
|
||||
bones/14/rotation = Quaternion(-0.00153534, -0.704023, 0.70978, -0.023698)
|
||||
bones/15/position = Vector3(-0.169587, -0.207477, 0.0975888)
|
||||
bones/16/position = Vector3(0.202683, -0.196121, -0.0935159)
|
||||
|
||||
[node name="AnimationPlayer" parent="Mesh" index="1"]
|
||||
autoplay = "Idle"
|
||||
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -65,6 +65,7 @@ func _input(event):
|
||||
|
||||
if Input.is_action_just_pressed("jump"):
|
||||
jumping = true
|
||||
animation_player.play("Jump")
|
||||
|
||||
if event.is_action_pressed("esc") and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
@@ -108,6 +109,7 @@ func walk(delta: float) -> Vector3:
|
||||
var _forward: Vector3 = neck.global_transform.basis * Vector3(move_dir.x, 0, move_dir.y)
|
||||
var walk_dir: Vector3 = Vector3(_forward.x, 0, _forward.z).normalized()
|
||||
walk_vel = walk_vel.move_toward(walk_dir * speed * move_dir.length(), acceleration * delta)
|
||||
|
||||
if walk_vel:
|
||||
animation_player.play("Walk")
|
||||
else:
|
||||
@@ -117,6 +119,8 @@ func walk(delta: float) -> Vector3:
|
||||
|
||||
func _gravity(delta: float) -> Vector3:
|
||||
grav_vel = Vector3.ZERO if is_on_floor() else grav_vel.move_toward(Vector3(0, velocity.y - gravity, 0), gravity * delta)
|
||||
if not is_on_floor() and animation_player.current_animation.begins_with("Idle"):
|
||||
animation_player.play("Fall")
|
||||
return grav_vel
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user