From 1029a5ea27c0e3acc56553bd4ddba2bc7ddda7a0 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 5 Feb 2024 10:36:26 +0100 Subject: [PATCH] Improved animations --- client/Main.tscn | 14 +++++++---- client/camera/Camera.gd | 7 +++--- .../{Animation.gd => AnimationController.gd} | 1 + client/player/Player.tscn | 24 ++++++++++++++++--- 4 files changed, 35 insertions(+), 11 deletions(-) rename client/player/{Animation.gd => AnimationController.gd} (97%) diff --git a/client/Main.tscn b/client/Main.tscn index de63e5f..0658059 100644 --- a/client/Main.tscn +++ b/client/Main.tscn @@ -90,16 +90,20 @@ autostart = true [node name="World" type="Node3D" parent="."] -[node name="Pivot" type="Node3D" parent="World"] +[node name="Follow" type="Node3D" parent="World"] -[node name="Camera" type="Camera3D" parent="World/Pivot" node_paths=PackedStringArray("center")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 7, 15) +[node name="Pivot" type="Node3D" parent="World/Follow"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) + +[node name="Camera" type="Camera3D" parent="World/Follow/Pivot" node_paths=PackedStringArray("follow", "pivot")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.5, 7.5) current = true fov = 30.0 size = 10.0 -far = 100.0 +far = 1000.0 script = ExtResource("18_wogcj") -center = NodePath("..") +follow = NodePath("../..") +pivot = NodePath("..") follow_speed = 5.0 [node name="Sun" type="DirectionalLight3D" parent="World"] diff --git a/client/camera/Camera.gd b/client/camera/Camera.gd index e91a085..ad0e3ea 100644 --- a/client/camera/Camera.gd +++ b/client/camera/Camera.gd @@ -1,17 +1,18 @@ extends Camera3D -@export var center: Node3D +@export var follow: Node3D +@export var pivot: Node3D @export var follow_speed: float func _ready(): Global.camera = self - look_at(center.position) + look_at(pivot.position) func _process(delta): if Global.player == null: return - center.position = lerp(center.position, Global.player.position, follow_speed * delta) + follow.position = lerp(follow.position, Global.player.position, follow_speed * delta) # @export var shake_strength: float # var noise = FastNoiseLite.new() diff --git a/client/player/Animation.gd b/client/player/AnimationController.gd similarity index 97% rename from client/player/Animation.gd rename to client/player/AnimationController.gd index a283839..df087b4 100644 --- a/client/player/Animation.gd +++ b/client/player/AnimationController.gd @@ -1,3 +1,4 @@ +class_name AnimationController extends Node @export var character: Character diff --git a/client/player/Player.tscn b/client/player/Player.tscn index d9e5fbe..c207176 100644 --- a/client/player/Player.tscn +++ b/client/player/Player.tscn @@ -1,10 +1,12 @@ -[gd_scene load_steps=8 format=3 uid="uid://2lcnu3dy54lx"] +[gd_scene load_steps=10 format=3 uid="uid://2lcnu3dy54lx"] [ext_resource type="Script" path="res://player/Player.gd" id="1_8gebs"] [ext_resource type="PackedScene" uid="uid://dnr3o1rbkqpgu" path="res://assets/female/Female.blend" id="2_8nah6"] [ext_resource type="PackedScene" uid="uid://2bbycjulf00g" path="res://character/health/HealthComponent.tscn" id="2_np5ag"] +[ext_resource type="PackedScene" uid="uid://dlhdudao4ondv" path="res://assets/sword/Sword.blend" id="3_c4wr7"] +[ext_resource type="PackedScene" uid="uid://cgqbkj8wbcatv" path="res://assets/hair/PonyTail.blend" id="3_umw6q"] [ext_resource type="FontFile" uid="uid://b7mov13kwi8u8" path="res://assets/font/ubuntu_nf_regular.ttf" id="4_76ehj"] -[ext_resource type="Script" path="res://player/Animation.gd" id="5_d4uw4"] +[ext_resource type="Script" path="res://player/AnimationController.gd" id="4_i2ybk"] [ext_resource type="AnimationLibrary" uid="uid://c355hn01ye2hd" path="res://assets/animations/human.blend" id="6_fl6or"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_2f50n"] @@ -19,6 +21,20 @@ model = NodePath("Model") [node name="Female" parent="Model" instance=ExtResource("2_8nah6")] +[node name="BoneAttachment3D" type="BoneAttachment3D" parent="Model/Female/Armature/GeneralSkeleton" index="2"] +transform = Transform3D(0, -1, 0, 0, 0, -1, 1, 0, 0, -0.609469, 1.26691, -0.0234125) +bone_name = "RightMiddleProximal" +bone_idx = 44 + +[node name="Sword" parent="Model/Female/Armature/GeneralSkeleton/BoneAttachment3D" instance=ExtResource("3_c4wr7")] + +[node name="BoneAttachment3D2" type="BoneAttachment3D" parent="Model/Female/Armature/GeneralSkeleton" index="3"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.57651e-10, 1.37156, -0.0247111) +bone_name = "Head" +bone_idx = 12 + +[node name="PonyTail" parent="Model/Female/Armature/GeneralSkeleton/BoneAttachment3D2" instance=ExtResource("3_umw6q")] + [node name="Collision" type="CollisionShape3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0) shape = SubResource("CapsuleShape3D_2f50n") @@ -35,7 +51,7 @@ font_size = 128 outline_size = 6 [node name="Animation" type="Node" parent="." node_paths=PackedStringArray("character", "animation_player")] -script = ExtResource("5_d4uw4") +script = ExtResource("4_i2ybk") character = NodePath("..") animation_player = NodePath("../AnimationPlayer") @@ -47,3 +63,5 @@ libraries = { "human": ExtResource("6_fl6or") } playback_default_blend_time = 0.2 + +[editable path="Model/Female"]