This commit is contained in:
parent
fb4f550890
commit
5d7d4e90bc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -2,8 +2,6 @@ extends Node3D
|
||||||
|
|
||||||
@onready var animation: AnimationNodeStateMachinePlayback = $AnimationTree.get("parameters/playback")
|
@onready var animation: AnimationNodeStateMachinePlayback = $AnimationTree.get("parameters/playback")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
signal anim_check_grab(position: Vector3)
|
signal anim_check_grab(position: Vector3)
|
||||||
|
|
||||||
var pickup_animation_in_progress = false
|
var pickup_animation_in_progress = false
|
||||||
|
|
BIN
godot/Models/grape_man.glb (Stored with Git LFS)
BIN
godot/Models/grape_man.glb (Stored with Git LFS)
Binary file not shown.
|
@ -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="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"]
|
[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"]
|
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_y2dr5"]
|
||||||
xfade_time = 0.3
|
xfade_time = 0.3
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_ubbuf"]
|
|
||||||
xfade_time = 0.3
|
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_6mfdu"]
|
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_6mfdu"]
|
||||||
states/IdleEmpty/node = SubResource("AnimationNodeBlendTree_ojr1k")
|
states/IdleEmpty/node = SubResource("AnimationNodeBlendTree_ojr1k")
|
||||||
states/IdleEmpty/position = Vector2(315, 186)
|
states/IdleEmpty/position = Vector2(315, 186)
|
||||||
states/IdleHold/node = SubResource("AnimationNodeBlendTree_v72vt")
|
states/IdleHold/node = SubResource("AnimationNodeBlendTree_v72vt")
|
||||||
states/IdleHold/position = Vector2(592, 349)
|
states/IdleHold/position = Vector2(592, 349)
|
||||||
states/Pickup/node = SubResource("AnimationNodeAnimation_rrdxi")
|
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/node = SubResource("AnimationNodeBlendTree_6rmmo")
|
||||||
states/WalkEmpty/position = Vector2(619, 219)
|
states/WalkEmpty/position = Vector2(548, 208)
|
||||||
states/WalkHold/node = SubResource("AnimationNodeBlendTree_kalnq")
|
states/WalkHold/node = SubResource("AnimationNodeBlendTree_kalnq")
|
||||||
states/WalkHold/position = Vector2(351, 323)
|
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)
|
graph_offset = Vector2(26, 89)
|
||||||
|
|
||||||
[node name="grape_man" instance=ExtResource("1_fh5yr")]
|
[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")
|
script = ExtResource("2_ksje8")
|
||||||
|
|
||||||
[node name="Skeleton3D" parent="rig" index="0"]
|
[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/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/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/3/rotation = Quaternion(-0.00997737, 0.100365, -0.694951, 0.711948)
|
||||||
|
|
|
@ -6,6 +6,7 @@ const JUMP_VELOCITY = 4.5
|
||||||
@export var horiz_sens = 0.25
|
@export var horiz_sens = 0.25
|
||||||
@export var vert_sens = 0.25
|
@export var vert_sens = 0.25
|
||||||
|
|
||||||
|
|
||||||
var holding: WeakRef = weakref(null)
|
var holding: WeakRef = weakref(null)
|
||||||
|
|
||||||
# Get the gravity from the project settings to be synced with RigidBody nodes.
|
# Get the gravity from the project settings to be synced with RigidBody nodes.
|
||||||
|
@ -29,9 +30,21 @@ func _input(event):
|
||||||
$CameraMount.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))
|
$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))
|
$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):
|
func _physics_process(delta):
|
||||||
|
if $grape_man.pickup_animation_in_progress:
|
||||||
|
return
|
||||||
|
|
||||||
# Add the gravity.
|
# Add the gravity.
|
||||||
if not is_on_floor():
|
if not is_on_floor():
|
||||||
velocity.y -= gravity * delta
|
velocity.y -= gravity * delta
|
||||||
|
@ -40,6 +53,10 @@ func _physics_process(delta):
|
||||||
# Get the input direction and handle the movement/deceleration.
|
# Get the input direction and handle the movement/deceleration.
|
||||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
# 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 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()
|
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||||
if direction:
|
if direction:
|
||||||
velocity.x = direction.x * SPEED
|
velocity.x = direction.x * SPEED
|
||||||
|
@ -49,10 +66,20 @@ func _physics_process(delta):
|
||||||
$grape_man.global_position.y,
|
$grape_man.global_position.y,
|
||||||
$grape_man.global_position.z - velocity.z,
|
$grape_man.global_position.z - velocity.z,
|
||||||
))
|
))
|
||||||
$grape_man.walk_empty()
|
if holding.get_ref():
|
||||||
|
$grape_man.walk_hold()
|
||||||
|
else:
|
||||||
|
$grape_man.walk_empty()
|
||||||
else:
|
else:
|
||||||
$grape_man.idle_empty()
|
if holding.get_ref():
|
||||||
|
$grape_man.idle_hold()
|
||||||
|
else:
|
||||||
|
$grape_man.idle_empty()
|
||||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||||
velocity.z = move_toward(velocity.z, 0, SPEED)
|
velocity.z = move_toward(velocity.z, 0, SPEED)
|
||||||
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_grape_man_anim_check_grab(_position):
|
||||||
|
holding = weakref(self)
|
||||||
|
|
|
@ -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)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1.39043)
|
||||||
current = true
|
current = true
|
||||||
fov = 50.0
|
fov = 50.0
|
||||||
|
|
||||||
|
[connection signal="anim_check_grab" from="grape_man" to="." method="_on_grape_man_anim_check_grab"]
|
||||||
|
|
Loading…
Reference in New Issue