Compare commits

...

6 Commits

Author SHA1 Message Date
Spencer Killen 6568462d0a
Merge branch 'master' of https://git.sjkillen.ca/sjkillen/ABGJ-23 2023-08-19 14:50:42 -06:00
Spencer Killen 158fc450f8
a 2023-08-19 14:49:36 -06:00
Spencer Killen 5a9e2575bf
a 2023-08-19 12:27:23 -06:00
Spencer Killen bfe712c456
Merge remote-tracking branch 'origin/Player' 2023-08-19 11:59:59 -06:00
Spencer Killen 0adc2c92e2
a 2023-08-19 11:58:20 -06:00
ncusimano 61cd28172c Camera Updates 2023-08-19 11:30:53 -06:00
12 changed files with 249 additions and 76 deletions

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

@ -9025,6 +9025,14 @@ _subresources={
"slice_99/start_frame": 0,
"slices/amount": null
}
},
"nodes": {
"PATH:AnimationPlayer": {
"import_tracks/position": 0,
"import_tracks/rotation": 0,
"import_tracks/scale": 0,
"optimizer/enabled": false
}
}
}
gltf/embedded_image_handling=1

View File

@ -1,17 +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/rotation = Quaternion(0.06565, 0, 0, 0.997843)
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, 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, 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

@ -5,17 +5,18 @@ const SPEED = 5.0
const JUMP_VELOCITY = 4.5
@export var horiz_sens = 0.25
@export var vert_sens = 0.25
var playerCam
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
playerCam = get_node("CameraMount") as Node3D
$CameraMount.global_rotation.x = clampf($CameraMount.global_rotation.x, deg_to_rad(-60), deg_to_rad(-11))
func _process(delta):
func _process(_delta):
# Brings your mouse out of the window if you press escape. Add pause screen function here?
if Input.is_action_pressed("ui_cancel"):
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
@ -25,9 +26,11 @@ func _input(event):
# Handle the rotation of the camera using mouse movement.
if event is InputEventMouseMotion:
rotate_y(deg_to_rad(-event.relative.x * horiz_sens))
playerCam.rotate_x(deg_to_rad(-event.relative.y * vert_sens))
$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.
if not is_on_floor():
@ -41,7 +44,14 @@ func _physics_process(delta):
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
$grape_man.look_at(Vector3(
$grape_man.global_position.x - velocity.x,
$grape_man.global_position.y,
$grape_man.global_position.z - velocity.z,
))
$grape_man.walk_empty()
else:
$grape_man.idle_empty()
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)

View File

@ -1,28 +1,22 @@
[gd_scene load_steps=6 format=3 uid="uid://7utef1nnena8"]
[gd_scene load_steps=4 format=3 uid="uid://7utef1nnena8"]
[ext_resource type="Script" path="res://Player.gd" id="1_7gpdp"]
[ext_resource type="Texture2D" uid="uid://vw0x1higed4d" path="res://Default Orange.png" id="2_s5i4o"]
[ext_resource type="PackedScene" uid="uid://bgoo1lbt28na" path="res://Models/grape_man.tscn" id="2_hg0av"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_kb4ms"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_1e11l"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_npbs0"]
albedo_texture = ExtResource("2_s5i4o")
[node name="Player" type="CharacterBody3D"]
script = ExtResource("1_7gpdp")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("CapsuleShape3D_kb4ms")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("CapsuleMesh_1e11l")
surface_material_override/0 = SubResource("StandardMaterial3D_npbs0")
[node name="grape_man" parent="." instance=ExtResource("2_hg0av")]
[node name="CameraMount" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.3, 0)
[node name="PlayerCam" type="Camera3D" parent="CameraMount"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 11.9417)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1.39043)
current = true
fov = 50.0

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.551151, 0, 0.834406, 0, 1, 0, -0.834406, 0, 0.551151, 1.041, 0.45, 0.03)
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"]