diff --git a/blends/giant.blend b/blends/giant.blend index 2db30cd..b6745d5 100644 Binary files a/blends/giant.blend and b/blends/giant.blend differ diff --git a/blends/giant.blend1 b/blends/giant.blend1 new file mode 100644 index 0000000..fdefc2d Binary files /dev/null and b/blends/giant.blend1 differ diff --git a/godot/Models/GrabPointLocation.gd b/godot/Models/GrabPointLocation.gd new file mode 100644 index 0000000..8065702 --- /dev/null +++ b/godot/Models/GrabPointLocation.gd @@ -0,0 +1,7 @@ +extends Node3D + +func _ready(): + set_as_top_level(true) + +func _process(_delta): + global_transform.origin = $"..".get_pickup_bone_location() diff --git a/godot/Models/grape_animations/pickup.res b/godot/Models/grape_animations/pickup.res index d6f4b0d..199e933 100644 Binary files a/godot/Models/grape_animations/pickup.res and b/godot/Models/grape_animations/pickup.res differ diff --git a/godot/Models/grape_animations/upper_body_holding.res b/godot/Models/grape_animations/upper_body_holding.res index fbcd0a2..7badc09 100644 Binary files a/godot/Models/grape_animations/upper_body_holding.res and b/godot/Models/grape_animations/upper_body_holding.res differ diff --git a/godot/Models/grape_animations/upper_body_idle.res.res b/godot/Models/grape_animations/upper_body_idle.res.res index fd30d7a..0f2924d 100644 Binary files a/godot/Models/grape_animations/upper_body_idle.res.res and b/godot/Models/grape_animations/upper_body_idle.res.res differ diff --git a/godot/Models/grape_animations/walk.res b/godot/Models/grape_animations/walk.res index ab7ac5f..d0c4987 100644 Binary files a/godot/Models/grape_animations/walk.res and b/godot/Models/grape_animations/walk.res differ diff --git a/godot/Models/grape_man.glb b/godot/Models/grape_man.glb index c21386a..df8336d 100644 --- a/godot/Models/grape_man.glb +++ b/godot/Models/grape_man.glb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6c07b7b68ef5daf21301084c31b4e5cc47f06d9c67a10aa4038853fb36ca14cf -size 659020 +oid sha256:b5935dfd7a74d82cc011bea9fe5720a2ab9bbb2478a42001dc14822af6a4f833 +size 659376 diff --git a/godot/Models/grape_man.tscn b/godot/Models/grape_man.tscn index 6623e6b..1110420 100644 --- a/godot/Models/grape_man.tscn +++ b/godot/Models/grape_man.tscn @@ -153,7 +153,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.10292, 0, 0, 0.99469) +bones/0/rotation = Quaternion(0.0962932, 0, 0, 0.995353) 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) @@ -166,13 +166,10 @@ 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"] +[node name="OmniLight3D" type="OmniLight3D" parent="." index="2"] 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"] +[node name="AnimationTree" type="AnimationTree" parent="." index="3"] tree_root = SubResource("AnimationNodeStateMachine_6mfdu") anim_player = NodePath("../AnimationPlayer") active = true @@ -181,11 +178,11 @@ parameters/IdleHold/Add2/add_amount = 1.0 parameters/WalkEmpty/Add2/add_amount = 1.0 parameters/WalkHold/Add2/add_amount = 1.0 -[node name="drop" type="AudioStreamPlayer" parent="." index="5"] +[node name="drop" type="AudioStreamPlayer" parent="." index="4"] stream = ExtResource("3_c648b") -[node name="pickup" type="AudioStreamPlayer" parent="." index="6"] +[node name="pickup" type="AudioStreamPlayer" parent="." index="5"] stream = ExtResource("4_nvurj") -[node name="chuckle" type="AudioStreamPlayer" parent="." index="7"] +[node name="chuckle" type="AudioStreamPlayer" parent="." index="6"] stream = ExtResource("5_b32re") diff --git a/godot/Models/slime.tscn b/godot/Models/slime.tscn index 3e456d2..cd19e03 100644 --- a/godot/Models/slime.tscn +++ b/godot/Models/slime.tscn @@ -29,13 +29,13 @@ transitions = ["Walk", "Idle", SubResource("AnimationNodeStateMachineTransition_ script = ExtResource("2_xo27e") [node name="Skeleton3D" parent="Armature" index="0"] -bones/1/position = Vector3(0, 0.437354, 0) +bones/1/position = Vector3(0, 0.419783, 0) bones/2/rotation = Quaternion(-0.0627444, 0.00212883, -0.213248, 0.974979) bones/3/rotation = Quaternion(0.100834, -0.698956, 0.0125015, 0.707911) -bones/7/rotation = Quaternion(-0.236485, 2.38279e-09, 2.70266e-09, 0.971635) -bones/8/rotation = Quaternion(0.263182, -9.32379e-10, -4.07392e-10, 0.964746) -bones/10/rotation = Quaternion(0.224729, -5.42036e-08, -5.94067e-08, 0.974421) -bones/11/rotation = Quaternion(-0.270178, 7.30152e-08, 3.38983e-08, 0.962811) +bones/7/rotation = Quaternion(-0.259966, 2.31658e-09, 2.75962e-09, 0.965618) +bones/8/rotation = Quaternion(0.184716, -8.96583e-10, -4.81081e-10, 0.982792) +bones/10/rotation = Quaternion(0.255235, -5.60434e-08, -5.76742e-08, 0.966879) +bones/11/rotation = Quaternion(-0.18748, 7.5629e-08, 2.75785e-08, 0.982268) [node name="AnimationTree" type="AnimationTree" parent="." index="2"] tree_root = SubResource("AnimationNodeStateMachine_prt7l") diff --git a/godot/Player.gd b/godot/Player.gd index d0d5d44..686aef7 100644 --- a/godot/Player.gd +++ b/godot/Player.gd @@ -1,12 +1,13 @@ extends CharacterBody3D -const SPEED = 5.0 +const SPEED = 0.5 const JUMP_VELOCITY = 4.5 @export var horiz_sens = 0.25 @export var vert_sens = 0.25 +var target: WeakRef = weakref(null) var holding: WeakRef = weakref(null) # Get the gravity from the project settings to be synced with RigidBody nodes. @@ -22,6 +23,10 @@ func _process(_delta): if Input.is_action_pressed("ui_cancel"): Input.mouse_mode = Input.MOUSE_MODE_VISIBLE + var obj = holding.get_ref() + if obj: + obj.global_transform.origin = $grape_man.get_pickup_bone_location() + func _input(event): # Handle the rotation of the camera using mouse movement. @@ -34,7 +39,7 @@ func _input(event): if Input.is_action_just_pressed("ui_accept"): var obj = holding.get_ref() if obj: - holding = weakref(null) + drop() $grape_man/drop.play() else: $grape_man/pickup.play() @@ -82,6 +87,31 @@ func _physics_process(delta): move_and_slide() +func drop(): + var obj = holding.get_ref() + if not obj: + print("dropped, but wasn't holding anything?") + return + remove_collision_exception_with(obj) + obj.set_process(true) + holding = weakref(null) func _on_grape_man_anim_check_grab(_position): - holding = weakref(self) + var obj = target.get_ref() + if not obj: + return + holding = target + target = weakref(null) + + add_collision_exception_with(obj) + obj.set_process(false) + +func _on_holster_enter(body): + if target.get_ref() or holding.get_ref() or "is_holdable" not in body: + return + target = weakref(body) + +func _on_holster_exit(body): + if target.get_ref() or holding.get_ref() or "is_holdable" not in body: + return + target = weakref(null) diff --git a/godot/player.tscn b/godot/player.tscn index 26a60af..ae1dc16 100644 --- a/godot/player.tscn +++ b/godot/player.tscn @@ -35,3 +35,7 @@ script = ExtResource("3_a68da") [node name="CollisionShape3D" type="CollisionShape3D" parent="Holster/Area3D"] transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0) shape = SubResource("SphereShape3D_6l1w6") + +[connection signal="anim_check_grab" from="grape_man" to="." method="_on_grape_man_anim_check_grab"] +[connection signal="body_entered" from="Holster/Area3D" to="." method="_on_holster_enter"] +[connection signal="body_exited" from="Holster/Area3D" to="." method="_on_holster_exit"] diff --git a/godot/slime_shared.gd b/godot/slime_shared.gd index 27b2d44..0dee155 100644 --- a/godot/slime_shared.gd +++ b/godot/slime_shared.gd @@ -1 +1,12 @@ extends CharacterBody3D + +var is_holdable: bool = true + +func _ready(): + $slime.idle() + +func walk(): + $slime.walk() + +func idle(): + $slime.idle() diff --git a/godot/slime_shared.tscn b/godot/slime_shared.tscn index b424c8c..1c473d5 100644 --- a/godot/slime_shared.tscn +++ b/godot/slime_shared.tscn @@ -1,9 +1,17 @@ -[gd_scene load_steps=3 format=3 uid="uid://dmtmign72vtlm"] +[gd_scene load_steps=4 format=3 uid="uid://dmtmign72vtlm"] [ext_resource type="Script" path="res://slime_shared.gd" id="1_gmj2r"] [ext_resource type="PackedScene" uid="uid://c3q6fva1c1baa" path="res://Models/slime.tscn" id="2_6u4ex"] +[sub_resource type="SphereShape3D" id="SphereShape3D_k5rhc"] +radius = 0.05 + [node name="slime_shared" type="CharacterBody3D"] script = ExtResource("1_gmj2r") [node name="slime" parent="." instance=ExtResource("2_6u4ex")] +transform = Transform3D(0.035, 0, 0, 0, 0.035, 0, 0, 0, 0.035, 0, 0, 0) + +[node name="slime_collision" type="CollisionShape3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0408143, 0) +shape = SubResource("SphereShape3D_k5rhc") diff --git a/godot/tests/test_pickup_slimes.tscn b/godot/tests/test_pickup_slimes.tscn new file mode 100644 index 0000000..cf3dacb --- /dev/null +++ b/godot/tests/test_pickup_slimes.tscn @@ -0,0 +1,26 @@ +[gd_scene load_steps=5 format=3 uid="uid://bax01mdng0pbb"] + +[ext_resource type="PackedScene" uid="uid://dmtmign72vtlm" path="res://slime_shared.tscn" id="2_dchwa"] +[ext_resource type="PackedScene" uid="uid://7utef1nnena8" path="res://player.tscn" id="2_fy870"] + +[sub_resource type="QuadMesh" id="QuadMesh_lasv3"] + +[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_x4p8c"] +data = PackedVector3Array(0.5, -0.5, 0, -0.5, -0.5, 0, 0.5, 0.5, 0, -0.5, -0.5, 0, -0.5, 0.5, 0, 0.5, 0.5, 0) + +[node name="test_pickup_slimes" type="Node3D"] + +[node name="slime_shared" parent="." instance=ExtResource("2_dchwa")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.127323, 0.879136) + +[node name="Player" parent="." instance=ExtResource("2_fy870")] + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +transform = Transform3D(5.40443, 0, 0, 0, -2.36235e-07, 5.40443, 0, -5.40443, -2.36235e-07, 0, -0.129765, 0) +mesh = SubResource("QuadMesh_lasv3") +skeleton = NodePath("") + +[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"] +shape = SubResource("ConcavePolygonShape3D_x4p8c")