This commit is contained in:
vengefulcartographer 2023-08-19 21:30:38 -06:00
commit 3562f24ad3
22 changed files with 177 additions and 38 deletions

Binary file not shown.

BIN
blends/giant.blend1 Normal file

Binary file not shown.

View File

@ -16,9 +16,9 @@
[ext_resource type="PackedScene" uid="uid://bf6bbqbaeh21y" path="res://Models/rocks/rock_3.tscn" id="14_1ahqw"]
[ext_resource type="PackedScene" uid="uid://bj8le45u845v3" path="res://Models/beach_decor/floatie.tscn" id="15_2v7p7"]
[ext_resource type="PackedScene" uid="uid://dhrnbubumgi5h" path="res://Models/buildings/buildingruined.tscn" id="15_6cbuu"]
[ext_resource type="PackedScene" uid="uid://bgoo1lbt28na" path="res://Models/grape_man.tscn" id="21_5uj16"]
[ext_resource type="PackedScene" uid="uid://dvpank15vkvtv" path="res://Models/beach_decor/parsol.tscn" id="21_dlhqg"]
[ext_resource type="PackedScene" uid="uid://c3q6fva1c1baa" path="res://Models/slime.tscn" id="22_5oom1"]
[ext_resource type="PackedScene" uid="uid://c4s6y758n77lw" path="res://villager_shared.tscn" id="21_hxwg1"]
[ext_resource type="PackedScene" uid="uid://7utef1nnena8" path="res://player.tscn" id="22_cuxj6"]
[ext_resource type="PackedScene" uid="uid://b3aus2kigf8xt" path="res://Models/beach_decor/cooler.tscn" id="24_sl7ne"]
[ext_resource type="PackedScene" uid="uid://bw3k2c75qavce" path="res://Models/beach_decor/bucket.tscn" id="27_f3p1i"]
[ext_resource type="PackedScene" uid="uid://g4gmc0pwlak1" path="res://Models/buildings/fence.tscn" id="28_prydb"]
@ -245,11 +245,8 @@ transform = Transform3D(-6.55671e-08, 0, -1.5, 0, 1.5, 0, 1.5, 0, -6.55671e-08,
[node name="fence4" parent="Decorations/slimepen" instance=ExtResource("28_prydb")]
transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0, 1.40507, -2.10425)
[node name="grape_man" parent="." instance=ExtResource("21_5uj16")]
transform = Transform3D(0.065, 0, 0, 0, 0.065, 0, 0, 0, 0.065, -0.219532, 2.64323, 0)
[node name="villager" parent="." instance=ExtResource("21_hxwg1")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.369429, 2.40957, -0.685529)
[node name="slime" parent="." instance=ExtResource("22_5oom1")]
transform = Transform3D(0.035, 0, 0, 0, 0.035, 0, 0, 0, 0.035, -0.240886, 2.72271, 0.267039)
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.965509, 0.26037, 0, -0.26037, 0.965509, 0, 5.42228, 4.14616)
[node name="Player" parent="." instance=ExtResource("22_cuxj6")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.192051, 2.60275, 0)

View File

@ -0,0 +1,7 @@
extends Node3D
func _ready():
set_as_top_level(true)
func _process(_delta):
global_transform.origin = $"..".get_pickup_bone_location()

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

Binary file not shown.

View File

@ -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")

View File

@ -28,5 +28,17 @@ animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
_subresources={
"materials": {
"50": {
"use_external/enabled": true,
"use_external/path": "res://Textures/rock.tres"
}
},
"nodes": {
"PATH:root/node_id4": {
"generate/physics": true
}
}
}
gltf/embedded_image_handling=1

View File

@ -28,5 +28,17 @@ animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
_subresources={
"materials": {
"50": {
"use_external/enabled": true,
"use_external/path": "res://Textures/rock.tres"
}
},
"nodes": {
"PATH:root/node_id4": {
"generate/physics": true
}
}
}
gltf/embedded_image_handling=1

View File

@ -28,5 +28,17 @@ animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
_subresources={
"materials": {
"50": {
"use_external/enabled": true,
"use_external/path": "res://Textures/rock.tres"
}
},
"nodes": {
"PATH:root/node_id4": {
"generate/physics": true
}
}
}
gltf/embedded_image_handling=1

View File

@ -1,7 +1,12 @@
extends Node3D
@onready var animation_state: AnimationNodeStateMachinePlayback = $AnimationTree.get("parameters/playback")
@export var colors: Array[Color]
func _ready():
var color = colors[randi() % colors.size()]
$Armature/Skeleton3D/Slime.get_active_material(3).albedo_color = color
func walk():
animation_state.travel("Walk")

View File

@ -27,15 +27,16 @@ transitions = ["Walk", "Idle", SubResource("AnimationNodeStateMachineTransition_
[node name="slime" instance=ExtResource("1_jttw0")]
script = ExtResource("2_xo27e")
colors = Array[Color]([Color(0, 0.113725, 0.905882, 1), Color(0.592157, 0, 0.243137, 1), Color(0.513726, 0.360784, 0, 1), Color(0, 0.470588, 0.32549, 1), Color(0.423529, 0, 0.54902, 1)])
[node name="Skeleton3D" parent="Armature" index="0"]
bones/1/position = Vector3(0, 0.437354, 0)
bones/1/position = Vector3(0, 0.529453, 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.1315, 2.65747e-09, 2.43309e-09, 0.991316)
bones/8/rotation = Quaternion(0.585182, -1.01606e-09, -5.40585e-11, 0.810902)
bones/10/rotation = Quaternion(0.0879173, -4.54741e-08, -6.63271e-08, 0.996128)
bones/11/rotation = Quaternion(-0.607325, 5.52851e-08, 5.85139e-08, 0.794453)
[node name="AnimationTree" type="AnimationTree" parent="." index="2"]
tree_root = SubResource("AnimationNodeStateMachine_prt7l")

View File

@ -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,19 +23,24 @@ 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.
if event is InputEventMouseMotion:
rotate_y(deg_to_rad(-event.relative.x * horiz_sens))
$CameraMount.rotate_x(deg_to_rad(-event.relative.y * vert_sens))
$grape_man.rotate_y(deg_to_rad(event.relative.x * horiz_sens))
var roty = deg_to_rad(event.relative.x * horiz_sens)
$grape_man.rotate_y(roty)
$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)
drop()
$grape_man/drop.play()
else:
$grape_man/pickup.play()
@ -82,6 +88,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 not target.get_ref() or holding.get_ref() or "is_holdable" not in body:
return
target = weakref(null)

View File

@ -1,10 +1,10 @@
extends CharacterBody3D
extends SharedSlime
var rng = RandomNumberGenerator.new()
@export var target_location_xz = transform.origin * Vector3(1, 0, 1)
@export var location_xz = transform.origin * Vector3(1, 0, 1)
@export var target_direction_xz = (transform.basis * Vector3(1, 0, 1)).normalized()
@export var direction_xz = (transform.basis * Vector3(1, 0, 1)).normalized()
@onready var target_location_xz = transform.origin * Vector3(1, 0, 1)
@onready var location_xz = transform.origin * Vector3(1, 0, 1)
@onready var target_direction_xz = (transform.basis * Vector3(1, 0, 1)).normalized()
@onready var direction_xz = (transform.basis * Vector3(1, 0, 1)).normalized()
var task = "idle"
# Percentage chances of the character performing certain actions while idle.
@ -34,6 +34,7 @@ func _process(_delta):
match task:
"idle":
idle()
task = rng.randf_range(0, 100)
# 3% chance to walk somewhere.
@ -51,6 +52,7 @@ func _process(_delta):
task = "idle"
"walk":
walk()
# Get the direction to the target in z-x plane.
target_direction_xz = (location_xz.direction_to(target_location_xz) * Vector3(1, 0, 1)).normalized()

View File

@ -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"]

View File

@ -1 +1,14 @@
extends CharacterBody3D
class_name SharedSlime
var is_holdable: bool = true
func _ready():
$slime.foo()
$slime.idle()
func walk():
$slime.walk()
func idle():
$slime.idle()

View File

@ -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")

View File

@ -0,0 +1,26 @@
[gd_scene load_steps=5 format=3 uid="uid://bax01mdng0pbb"]
[ext_resource type="PackedScene" uid="uid://7utef1nnena8" path="res://player.tscn" id="2_fy870"]
[ext_resource type="PackedScene" uid="uid://c4s6y758n77lw" path="res://villager_shared.tscn" id="2_oxniy"]
[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="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")
[node name="villager" parent="." instance=ExtResource("2_oxniy")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.513896)

View File

@ -0,0 +1,12 @@
[gd_scene load_steps=3 format=3 uid="uid://c4s6y758n77lw"]
[ext_resource type="PackedScene" uid="uid://dmtmign72vtlm" path="res://slime_shared.tscn" id="1_qm1jp"]
[ext_resource type="Script" path="res://Villager.gd" id="2_uf6mh"]
[node name="villager" instance=ExtResource("1_qm1jp")]
script = ExtResource("2_uf6mh")
walk_chance = 0.1
spin_chance = 0.2
walk_speed = 0.5
dir_correction_rate = 0.95
dir_accuracy = 0.00174533