This commit is contained in:
Spencer Killen 2023-08-19 14:49:36 -06:00
parent 5a9e2575bf
commit 158fc450f8
Signed by: sjkillen
GPG Key ID: F307025B65C860BA
11 changed files with 229 additions and 83 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,7 +1,7 @@
extends Node3D
var upper_body_animation: AnimationPlayer
var full_body_animation: AnimationPlayer
@onready var animation: AnimationNodeStateMachinePlayback = $AnimationTree.get("parameters/playback")
signal anim_check_grab(position: Vector3)
@ -9,37 +9,29 @@ signal anim_check_grab(position: Vector3)
var pickup_animation_in_progress = false
signal pickup_animation_finished
func _ready():
upper_body_animation = $AnimationPlayer.duplicate()
add_child(upper_body_animation)
full_body_animation = $AnimationPlayer
full_body_animation.play("Idle")
upper_body_animation.play("UpperBodyIdle")
func idle_empty():
animation.travel("IdleEmpty")
func hold():
func walk_empty():
animation.travel("WalkEmpty")
func walk_hold():
if pickup_animation_in_progress:
await pickup_animation_finished
upper_body_animation.play("UpperBodyHolding")
animation.travel("WalkHold")
func pickup():
pickup_animation_in_progress = true
full_body_animation.play("Pickup")
await full_body_animation.animation_finished
full_body_animation.play("Idle")
upper_body_animation.play("UpperBodyIdle")
pickup_animation_in_progress = false
emit_signal("pickup_animation_finished")
animation.travel("Pickup")
func idle():
full_body_animation.play("Idle")
func drop():
full_body_animation.play("Idle")
upper_body_animation.play("UpperBodyIdle")
func walk():
full_body_animation.play("Walk")
func idle_hold():
if pickup_animation_in_progress:
await pickup_animation_finished
animation.travel("IdleHold")
func animation_key_grab():
emit_signal("anim_check_grab", $GrabPointLocation.global_transform)
func animation_key_pickup_completed():
pickup_animation_in_progress = false
emit_signal("pickup_animation_finished")

View File

@ -31,7 +31,7 @@ import_script/path=""
_subresources={
"animations": {
"Idle": {
"save_to_file/enabled": false,
"save_to_file/enabled": true,
"save_to_file/keep_custom_tracks": true,
"save_to_file/path": "res://Models/grape_animations/idle.res",
"settings/loop_mode": 1,
@ -1830,7 +1830,7 @@ _subresources={
"slices/amount": null
},
"Pickup": {
"save_to_file/enabled": false,
"save_to_file/enabled": true,
"save_to_file/keep_custom_tracks": true,
"save_to_file/path": "res://Models/grape_animations/pickup.res",
"settings/loop_mode": 0,
@ -3629,7 +3629,7 @@ _subresources={
"slices/amount": null
},
"UpperBodyHolding": {
"save_to_file/enabled": false,
"save_to_file/enabled": true,
"save_to_file/keep_custom_tracks": true,
"save_to_file/path": "res://Models/grape_animations/upper_body_holding.res",
"settings/loop_mode": 0,
@ -5428,7 +5428,7 @@ _subresources={
"slices/amount": null
},
"UpperBodyIdle": {
"save_to_file/enabled": false,
"save_to_file/enabled": true,
"save_to_file/keep_custom_tracks": true,
"save_to_file/path": "res://Models/grape_animations/upper_body_idle.res.res",
"settings/loop_mode": 0,
@ -7227,7 +7227,7 @@ _subresources={
"slices/amount": null
},
"Walk": {
"save_to_file/enabled": false,
"save_to_file/enabled": true,
"save_to_file/keep_custom_tracks": true,
"save_to_file/path": "res://Models/grape_animations/walk.res",
"settings/loop_mode": 1,

View File

@ -1,34 +1,186 @@
[gd_scene load_steps=3 format=3 uid="uid://bgoo1lbt28na"]
[gd_scene load_steps=38 format=3 uid="uid://bgoo1lbt28na"]
[ext_resource type="PackedScene" uid="uid://bhanbx2dyhv2d" path="res://Models/grape_man.glb" id="1_fh5yr"]
[ext_resource type="Script" path="res://Models/grape_man.gd" id="2_ksje8"]
[sub_resource type="AnimationNodeAdd2" id="AnimationNodeAdd2_a0vxm"]
filter_enabled = true
filters = ["rig/Skeleton3D:forearm.L", "rig/Skeleton3D:forearm.R", "rig/Skeleton3D:head", "rig/Skeleton3D:upper_arm.L", "rig/Skeleton3D:upper_arm.R"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_s8uqe"]
animation = &"UpperBodyIdle"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_4ft7i"]
animation = &"Idle"
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_ojr1k"]
graph_offset = Vector2(-312, -69)
nodes/Add2/node = SubResource("AnimationNodeAdd2_a0vxm")
nodes/Add2/position = Vector2(160, 80)
nodes/Animation/node = SubResource("AnimationNodeAnimation_4ft7i")
nodes/Animation/position = Vector2(0, 80)
"nodes/Animation 2/node" = SubResource("AnimationNodeAnimation_s8uqe")
"nodes/Animation 2/position" = Vector2(0, 220)
node_connections = [&"output", 0, &"Add2", &"Add2", 0, &"Animation", &"Add2", 1, &"Animation 2"]
[sub_resource type="AnimationNodeAdd2" id="AnimationNodeAdd2_4gk6k"]
filter_enabled = true
filters = ["rig/Skeleton3D:forearm.L", "rig/Skeleton3D:forearm.R", "rig/Skeleton3D:head", "rig/Skeleton3D:upper_arm.L", "rig/Skeleton3D:upper_arm.R"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_alnh1"]
animation = &"UpperBodyHolding"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_mbatu"]
animation = &"Idle"
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_v72vt"]
graph_offset = Vector2(-205.16, 19.99)
nodes/Add2/node = SubResource("AnimationNodeAdd2_4gk6k")
nodes/Add2/position = Vector2(260, 100)
nodes/Animation/node = SubResource("AnimationNodeAnimation_mbatu")
nodes/Animation/position = Vector2(60, 100)
"nodes/Animation 2/node" = SubResource("AnimationNodeAnimation_alnh1")
"nodes/Animation 2/position" = Vector2(20, 220)
nodes/output/position = Vector2(460, 140)
node_connections = [&"output", 0, &"Add2", &"Add2", 0, &"Animation", &"Add2", 1, &"Animation 2"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_rrdxi"]
animation = &"Pickup"
[sub_resource type="AnimationNodeAdd2" id="AnimationNodeAdd2_rd6bn"]
filter_enabled = true
filters = ["rig/Skeleton3D:forearm.L", "rig/Skeleton3D:forearm.R", "rig/Skeleton3D:head", "rig/Skeleton3D:upper_arm.L", "rig/Skeleton3D:upper_arm.R"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_7s7tg"]
animation = &"UpperBodyIdle"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_ir63n"]
animation = &"Walk"
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_6rmmo"]
graph_offset = Vector2(-358.186, -79.7423)
nodes/Add2/node = SubResource("AnimationNodeAdd2_rd6bn")
nodes/Add2/position = Vector2(140, 80)
nodes/Animation/node = SubResource("AnimationNodeAnimation_ir63n")
nodes/Animation/position = Vector2(-40, 60)
"nodes/Animation 2/node" = SubResource("AnimationNodeAnimation_7s7tg")
"nodes/Animation 2/position" = Vector2(-100, 180)
node_connections = [&"output", 0, &"Add2", &"Add2", 0, &"Animation", &"Add2", 1, &"Animation 2"]
[sub_resource type="AnimationNodeAdd2" id="AnimationNodeAdd2_sv87c"]
filter_enabled = true
filters = ["rig/Skeleton3D:forearm.L", "rig/Skeleton3D:forearm.R", "rig/Skeleton3D:head", "rig/Skeleton3D:upper_arm.L", "rig/Skeleton3D:upper_arm.R"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_y7bu0"]
animation = &"Walk"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_t2s01"]
animation = &"UpperBodyHolding"
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_kalnq"]
graph_offset = Vector2(-260.079, -48.5605)
nodes/Add2/node = SubResource("AnimationNodeAdd2_sv87c")
nodes/Add2/position = Vector2(120, 40)
nodes/Animation/node = SubResource("AnimationNodeAnimation_t2s01")
nodes/Animation/position = Vector2(-120, 160)
"nodes/Animation 2/node" = SubResource("AnimationNodeAnimation_y7bu0")
"nodes/Animation 2/position" = Vector2(-70.4947, 47.7517)
node_connections = [&"output", 0, &"Add2", &"Add2", 0, &"Animation 2", &"Add2", 1, &"Animation"]
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_8sw6d"]
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_71rn8"]
xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_cp7lp"]
xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_27n2r"]
xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_v26jl"]
xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_u0rau"]
xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_1hqga"]
xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_uekhs"]
xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_652wi"]
xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_sdgve"]
xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_otprv"]
xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_fbwhh"]
xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_4rq7a"]
xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_oange"]
xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_et4tx"]
xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_y2dr5"]
xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_ubbuf"]
xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_6mfdu"]
states/IdleEmpty/node = SubResource("AnimationNodeBlendTree_ojr1k")
states/IdleEmpty/position = Vector2(315, 186)
states/IdleHold/node = SubResource("AnimationNodeBlendTree_v72vt")
states/IdleHold/position = Vector2(592, 349)
states/Pickup/node = SubResource("AnimationNodeAnimation_rrdxi")
states/Pickup/position = Vector2(711, 105)
states/WalkEmpty/node = SubResource("AnimationNodeBlendTree_6rmmo")
states/WalkEmpty/position = Vector2(619, 219)
states/WalkHold/node = SubResource("AnimationNodeBlendTree_kalnq")
states/WalkHold/position = Vector2(351, 323)
transitions = ["Start", "IdleEmpty", SubResource("AnimationNodeStateMachineTransition_8sw6d"), "IdleEmpty", "WalkHold", SubResource("AnimationNodeStateMachineTransition_71rn8"), "WalkHold", "IdleEmpty", SubResource("AnimationNodeStateMachineTransition_cp7lp"), "WalkEmpty", "IdleEmpty", SubResource("AnimationNodeStateMachineTransition_27n2r"), "IdleEmpty", "WalkEmpty", SubResource("AnimationNodeStateMachineTransition_v26jl"), "IdleHold", "WalkHold", SubResource("AnimationNodeStateMachineTransition_u0rau"), "IdleHold", "WalkEmpty", SubResource("AnimationNodeStateMachineTransition_1hqga"), "WalkEmpty", "IdleHold", SubResource("AnimationNodeStateMachineTransition_uekhs"), "WalkHold", "IdleHold", SubResource("AnimationNodeStateMachineTransition_652wi"), "IdleEmpty", "Pickup", SubResource("AnimationNodeStateMachineTransition_sdgve"), "Pickup", "IdleEmpty", SubResource("AnimationNodeStateMachineTransition_otprv"), "IdleEmpty", "IdleHold", SubResource("AnimationNodeStateMachineTransition_fbwhh"), "IdleHold", "IdleEmpty", SubResource("AnimationNodeStateMachineTransition_4rq7a"), "WalkHold", "WalkEmpty", SubResource("AnimationNodeStateMachineTransition_oange"), "WalkEmpty", "WalkHold", SubResource("AnimationNodeStateMachineTransition_et4tx"), "Pickup", "IdleHold", SubResource("AnimationNodeStateMachineTransition_y2dr5"), "IdleHold", "Pickup", SubResource("AnimationNodeStateMachineTransition_ubbuf")]
graph_offset = Vector2(26, 89)
[node name="grape_man" instance=ExtResource("1_fh5yr")]
transform = Transform3D(0.065, 0, 0, 0, 0.065, 0, 0, 0, 0.065, 0, 0, 0)
script = ExtResource("2_ksje8")
[node name="Skeleton3D" parent="rig" index="0"]
bones/0/position = Vector3(0.00830117, 0.985943, 0.124772)
bones/0/rotation = Quaternion(0.838567, 0.0312173, -0.0173838, 0.543623)
bones/1/rotation = Quaternion(-0.0865421, 0.000700139, 0.000169413, 0.996248)
bones/2/rotation = Quaternion(-0.111076, -0.0110209, 0.0529719, 0.992338)
bones/3/rotation = Quaternion(0.467612, 0.0653885, -0.582913, 0.661268)
bones/0/rotation = Quaternion(0.0795036, 0, 0, 0.996835)
bones/1/rotation = Quaternion(-0.0891896, 1.18734e-07, -1.06322e-08, 0.996015)
bones/2/rotation = Quaternion(0.0133933, -1.19199e-07, 1.5966e-09, 0.99991)
bones/3/rotation = Quaternion(-0.00997737, 0.100365, -0.694951, 0.711948)
bones/4/rotation = Quaternion(0.0687327, -0.0343696, -0.655545, 0.751236)
bones/4/scale = Vector3(1.06418, 1.06418, 1.06418)
bones/5/rotation = Quaternion(0.467612, -0.0653885, 0.582913, 0.661268)
bones/4/scale = Vector3(1, 1, 1)
bones/5/rotation = Quaternion(-0.00997737, -0.100365, 0.694951, 0.711948)
bones/6/rotation = Quaternion(0.0687327, 0.0343696, 0.655545, 0.751236)
bones/6/scale = Vector3(1.06418, 1.06418, 1.06418)
bones/7/rotation = Quaternion(0.274903, 0.0722153, -0.0203558, 0.95854)
bones/8/rotation = Quaternion(0.197065, 6.31982e-16, -1.33238e-15, 0.98039)
bones/9/position = Vector3(0.155448, 0.891297, -0.0224623)
bones/9/rotation = Quaternion(0.91662, -0.0104789, -0.00138672, 0.39962)
bones/10/rotation = Quaternion(0.268897, 0.0200174, -0.0169533, 0.962812)
bones/14/position = Vector3(-0.155448, 0.891297, -0.0224622)
bones/14/rotation = Quaternion(0.966019, 0.00733452, 0.00761147, -0.258254)
bones/15/rotation = Quaternion(-0.0622384, -0.00553498, 0.0104557, 0.997991)
bones/6/scale = Vector3(1, 1, 1)
bones/7/rotation = Quaternion(0.0142813, -6.34259e-18, -4.44044e-16, 0.999898)
bones/10/rotation = Quaternion(0.105246, 0.0039338, -0.0113526, 0.994374)
bones/15/rotation = Quaternion(0.105246, -0.0039338, 0.0113526, 0.994374)
[node name="GrabPointLocation" type="Node3D" parent="." index="2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1.29365)
[node name="OmniLight3D" type="OmniLight3D" parent="." index="3"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.289473, 8.26292, 4.26359)
[node name="AnimationTree" type="AnimationTree" parent="." index="4"]
tree_root = SubResource("AnimationNodeStateMachine_6mfdu")
anim_player = NodePath("../AnimationPlayer")
active = true
parameters/IdleEmpty/Add2/add_amount = 1.0
parameters/IdleHold/Add2/add_amount = 1.0
parameters/WalkEmpty/Add2/add_amount = 1.0
parameters/WalkHold/Add2/add_amount = 1.0

View File

@ -6,12 +6,13 @@ const JUMP_VELOCITY = 4.5
@export var horiz_sens = 0.25
@export var vert_sens = 0.25
var holding: WeakRef = weakref(null)
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
func _ready():
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
$grape_man.drop()
$CameraMount.global_rotation.x = clampf($CameraMount.global_rotation.x, deg_to_rad(-60), deg_to_rad(-11))
@ -28,6 +29,7 @@ func _input(event):
$CameraMount.rotate_x(deg_to_rad(-event.relative.y * vert_sens))
$grape_man.rotate_y(deg_to_rad(event.relative.x * horiz_sens))
$CameraMount.global_rotation.x = clampf($CameraMount.global_rotation.x, deg_to_rad(-60), deg_to_rad(-11))
func _physics_process(delta):
# Add the gravity.
@ -47,9 +49,9 @@ func _physics_process(delta):
$grape_man.global_position.y,
$grape_man.global_position.z - velocity.z,
))
$grape_man.walk()
$grape_man.walk_empty()
else:
$grape_man.idle()
$grape_man.idle_empty()
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)

View File

@ -1,16 +1,16 @@
extends Node3D
func _on_walk_empty_pressed():
$grape_man.walk_empty()
func _on_walk_hold_pressed():
$grape_man.walk_hold()
func _on_idle_empty_pressed():
$grape_man.idle_empty()
func _on_idle_hold_pressed():
$grape_man.idle_hold()
func _on_pickup_pressed():
$grape_man.pickup()
func _on_drop_pressed():
$grape_man.drop()
func _on_idle_pressed():
$grape_man.idle()
func _on_walk_pressed():
$grape_man.walk()
func _on_hold_pressed():
$grape_man.hold()

View File

@ -30,31 +30,31 @@ offset_bottom = 15.0
grow_horizontal = 2
grow_vertical = 2
[node name="WalkEmpty" type="Button" parent="CanvasLayer/Control/VBoxContainer"]
layout_mode = 2
text = "WalkEmpty"
[node name="WalkHold" type="Button" parent="CanvasLayer/Control/VBoxContainer"]
layout_mode = 2
text = "WalkHold"
[node name="IdleEmpty" type="Button" parent="CanvasLayer/Control/VBoxContainer"]
layout_mode = 2
text = "IdleEmpty"
[node name="IdleHold" type="Button" parent="CanvasLayer/Control/VBoxContainer"]
layout_mode = 2
text = "IdleHold"
[node name="Pickup" type="Button" parent="CanvasLayer/Control/VBoxContainer"]
layout_mode = 2
text = "Pickup"
[node name="Hold" type="Button" parent="CanvasLayer/Control/VBoxContainer"]
layout_mode = 2
text = "Hold"
[node name="Drop" type="Button" parent="CanvasLayer/Control/VBoxContainer"]
layout_mode = 2
text = "Drop"
[node name="Idle" type="Button" parent="CanvasLayer/Control/VBoxContainer"]
layout_mode = 2
text = "Idle"
[node name="Walk" type="Button" parent="CanvasLayer/Control/VBoxContainer"]
layout_mode = 2
text = "Walk"
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(0.947434, 0, 0.319952, 0, 1, 0, -0.319952, 0, 0.947434, 0.401511, 0.45, 0.732763)
[connection signal="pressed" from="CanvasLayer/Control/VBoxContainer/WalkEmpty" to="." method="_on_walk_empty_pressed"]
[connection signal="pressed" from="CanvasLayer/Control/VBoxContainer/WalkHold" to="." method="_on_walk_hold_pressed"]
[connection signal="pressed" from="CanvasLayer/Control/VBoxContainer/IdleEmpty" to="." method="_on_idle_empty_pressed"]
[connection signal="pressed" from="CanvasLayer/Control/VBoxContainer/IdleHold" to="." method="_on_idle_hold_pressed"]
[connection signal="pressed" from="CanvasLayer/Control/VBoxContainer/Pickup" to="." method="_on_pickup_pressed"]
[connection signal="pressed" from="CanvasLayer/Control/VBoxContainer/Hold" to="." method="_on_hold_pressed"]
[connection signal="pressed" from="CanvasLayer/Control/VBoxContainer/Drop" to="." method="_on_drop_pressed"]
[connection signal="pressed" from="CanvasLayer/Control/VBoxContainer/Idle" to="." method="_on_idle_pressed"]
[connection signal="pressed" from="CanvasLayer/Control/VBoxContainer/Walk" to="." method="_on_walk_pressed"]