Improved attack animation

This commit is contained in:
Eduard Urbach 2024-02-13 11:56:04 +01:00
parent 38133969fc
commit 7347c85ca7
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
5 changed files with 31 additions and 3 deletions

View File

@ -1,2 +1,11 @@
class_name EnemyController
extends Controller
var enemy: Enemy
func _ready():
enemy = owner
func _process(_delta):
var direction := (Global.player.global_position - enemy.global_position).normalized()
enemy.set_direction(direction)

View File

@ -1,2 +1,7 @@
class_name Enemy
extends CharacterBody3D
signal direction_changed
func set_direction(direction: Vector3):
direction_changed.emit(direction)

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=12 format=3 uid="uid://cb2t7bvvf3gwh"]
[gd_scene load_steps=13 format=3 uid="uid://cb2t7bvvf3gwh"]
[ext_resource type="PackedScene" uid="uid://b358op5h1y83m" path="res://assets/slime/Slime.blend" id="1_1h1hj"]
[ext_resource type="Script" path="res://enemy/Enemy.gd" id="1_r5888"]
@ -7,6 +7,7 @@
[ext_resource type="PackedScene" uid="uid://6jpnl6c4fdvo" path="res://player/hud/HUDComponent.tscn" id="3_4jtio"]
[ext_resource type="PackedScene" uid="uid://bfvudkup0xsq4" path="res://enemy/loot/LootComponent.tscn" id="6_68kgw"]
[ext_resource type="PackedScene" uid="uid://dl4vcp04t8iyr" path="res://item/soul/Soul.tscn" id="7_i0rtb"]
[ext_resource type="Script" path="res://controller/EnemyController.gd" id="8_b7r6l"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_ub3kk"]
height = 0.5
@ -66,7 +67,11 @@ autoplay = "slime_idle"
max_value = 100.0
[node name="Movement" parent="." instance=ExtResource("3_2phqx")]
move_speed = 0.5
[node name="Loot" parent="." node_paths=PackedStringArray("health") instance=ExtResource("6_68kgw")]
health = NodePath("../Health")
drop = ExtResource("7_i0rtb")
[node name="EnemyController" type="Node" parent="."]
script = ExtResource("8_b7r6l")

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=17 format=3 uid="uid://2lcnu3dy54lx"]
[gd_scene load_steps=18 format=3 uid="uid://2lcnu3dy54lx"]
[ext_resource type="Script" path="res://player/Player.gd" id="1_8gebs"]
[ext_resource type="PackedScene" uid="uid://c8j7t4yg7anb0" path="res://assets/female/Female.blend" id="2_8nah6"]
@ -7,6 +7,7 @@
[ext_resource type="FontFile" uid="uid://b7mov13kwi8u8" path="res://assets/font/ubuntu_nf_regular.ttf" id="4_76ehj"]
[ext_resource type="Skin" uid="uid://bbqyiue1vj37f" path="res://assets/hoodie/Hoodie_Skin.tres" id="4_b1tg1"]
[ext_resource type="ArrayMesh" uid="uid://dbmluwi2atit" path="res://assets/hoodie/Hoodie_Mesh.res" id="5_mkrgn"]
[ext_resource type="PackedScene" uid="uid://ci3p21x2u7c6" path="res://assets/ue5/sword/SM_HeavenSword.glb" id="6_jgdba"]
[ext_resource type="PackedScene" uid="uid://6jpnl6c4fdvo" path="res://player/hud/HUDComponent.tscn" id="7_fwgtd"]
[ext_resource type="PackedScene" uid="uid://x102pryt2s5a" path="res://player/movement/MovementComponent.tscn" id="8_25qd0"]
[ext_resource type="PackedScene" uid="uid://d0onbq0ad1ap4" path="res://player/rotation/RotationComponent.tscn" id="9_agxqu"]
@ -52,6 +53,14 @@ layers = 512
mesh = ExtResource("5_mkrgn")
skin = ExtResource("4_b1tg1")
[node name="BoneAttachment3D2" type="BoneAttachment3D" parent="Model/Female/Armature/GeneralSkeleton" index="6"]
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/BoneAttachment3D2" instance=ExtResource("6_jgdba")]
transform = Transform3D(5.96046e-08, 1, 5.96046e-08, -0.927895, -8.9407e-08, 0.372842, 0.372842, 0, 0.927895, 1.19209e-07, 2.98023e-08, 0.0228834)
[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")

View File

@ -10,7 +10,7 @@ func _ready():
player.attacked.connect(attack)
func attack():
await get_tree().create_timer(0.5).timeout
await get_tree().create_timer(0.7).timeout
area.monitoring = true
await get_tree().create_timer(0.1).timeout
area.monitoring = false