This commit is contained in:
Spencer Killen 2023-08-19 15:42:56 -06:00
parent fb4f550890
commit 5d7d4e90bc
Signed by: sjkillen
GPG Key ID: F307025B65C860BA
12 changed files with 38 additions and 14 deletions

Binary file not shown.

BIN
blends/giant.blend1 Normal file

Binary file not shown.

View File

@ -2,8 +2,6 @@ extends Node3D
@onready var animation: AnimationNodeStateMachinePlayback = $AnimationTree.get("parameters/playback")
signal anim_check_grab(position: Vector3)
var pickup_animation_in_progress = false

BIN
godot/Models/grape_man.glb (Stored with Git LFS)

Binary file not shown.

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=38 format=3 uid="uid://bgoo1lbt28na"]
[gd_scene load_steps=37 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"]
@ -135,21 +135,18 @@ 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/Pickup/position = Vector2(734, 117)
states/WalkEmpty/node = SubResource("AnimationNodeBlendTree_6rmmo")
states/WalkEmpty/position = Vector2(619, 219)
states/WalkEmpty/position = Vector2(548, 208)
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")]
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")]
graph_offset = Vector2(26, 89)
[node name="grape_man" instance=ExtResource("1_fh5yr")]
@ -157,7 +154,7 @@ 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.08892, 0, 0, 0.996039)
bones/0/rotation = Quaternion(0.0861766, 0, 0, 0.99628)
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)

View File

@ -6,6 +6,7 @@ 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.
@ -30,8 +31,20 @@ func _input(event):
$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))
if Input.is_action_just_pressed("ui_accept"):
var obj = holding.get_ref()
if obj:
holding = weakref(null)
else:
$grape_man.pickup()
func _physics_process(delta):
if $grape_man.pickup_animation_in_progress:
return
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
@ -40,6 +53,10 @@ func _physics_process(delta):
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED
@ -49,10 +66,20 @@ func _physics_process(delta):
$grape_man.global_position.y,
$grape_man.global_position.z - velocity.z,
))
if holding.get_ref():
$grape_man.walk_hold()
else:
$grape_man.walk_empty()
else:
if holding.get_ref():
$grape_man.idle_hold()
else:
$grape_man.idle_empty()
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
move_and_slide()
func _on_grape_man_anim_check_grab(_position):
holding = weakref(self)

View File

@ -20,3 +20,5 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.3, 0)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1.39043)
current = true
fov = 50.0
[connection signal="anim_check_grab" from="grape_man" to="." method="_on_grape_man_anim_check_grab"]