diff --git a/Scenes/MeleeEnemyOrb.tscn b/Scenes/MeleeEnemyOrb.tscn index feedcd9..f780cc3 100644 --- a/Scenes/MeleeEnemyOrb.tscn +++ b/Scenes/MeleeEnemyOrb.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=4 format=3 uid="uid://bt5rolsyjmx55"] +[gd_scene load_steps=5 format=3 uid="uid://bt5rolsyjmx55"] [ext_resource type="PackedScene" uid="uid://bay1tvgtpfxns" path="res://Scenes/MeleeEnemySchmoove.tscn" id="1_0pxgq"] [ext_resource type="Script" path="res://Scripts/MeleeEnemy.cs" id="1_50och"] @@ -6,13 +6,28 @@ [sub_resource type="BoxShape3D" id="BoxShape3D_1nq5h"] size = Vector3(0.470892, 0.604331, 0.423598) +[sub_resource type="BoxShape3D" id="BoxShape3D_i1yvp"] +size = Vector3(0.470892, 0.604331, 0.423598) + [node name="MeleeEnemyOrb" type="Node3D"] [node name="CharacterBody3D" type="CharacterBody3D" parent="."] +collision_layer = 0 +collision_mask = 0 script = ExtResource("1_50och") [node name="CollisionShape3D" type="CollisionShape3D" parent="CharacterBody3D"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.475385, 0.143401) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0840461, 0.475385, 0.143401) shape = SubResource("BoxShape3D_1nq5h") [node name="meleeenemy - Updated" parent="CharacterBody3D" instance=ExtResource("1_0pxgq")] + +[node name="Area3D" type="Area3D" parent="CharacterBody3D"] +collision_layer = 0 +collision_mask = 2 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="CharacterBody3D/Area3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0840461, 0.475385, 0.143401) +shape = SubResource("BoxShape3D_i1yvp") + +[connection signal="body_entered" from="CharacterBody3D/Area3D" to="CharacterBody3D" method="OnHit"] diff --git a/Scenes/PiscesWitch.tscn b/Scenes/PiscesWitch.tscn index 2675d30..1d8b66b 100644 --- a/Scenes/PiscesWitch.tscn +++ b/Scenes/PiscesWitch.tscn @@ -14,6 +14,7 @@ radius = 0.704872 height = 1.67894 [node name="Pisces" type="CharacterBody3D" groups=["Player"]] +transform = Transform3D(0.33, 0, 0, 0, 0.33, 0, 0, 0, 0.33, 0, 0, 0) script = ExtResource("1_tinf8") _fireProjectile = ExtResource("2_ciujd") _altFireProjectile = ExtResource("3_0of1i") diff --git a/Scenes/ShotgunBullet.tscn b/Scenes/ShotgunBullet.tscn index 42beaf6..b4fd87d 100644 --- a/Scenes/ShotgunBullet.tscn +++ b/Scenes/ShotgunBullet.tscn @@ -1,10 +1,16 @@ -[gd_scene load_steps=4 format=3 uid="uid://bq40xbqibrk1y"] +[gd_scene load_steps=6 format=3 uid="uid://bq40xbqibrk1y"] [ext_resource type="Script" path="res://Scripts/ShotgunBullet.cs" id="1_binxs"] [ext_resource type="Texture2D" uid="uid://borp7xvlfdcmq" path="res://Textures/Projectiles/bubble.png" id="2_dv80m"] -[sub_resource type="SphereShape3D" id="SphereShape3D_o6kys"] -radius = 0.2 +[sub_resource type="CylinderShape3D" id="CylinderShape3D_eme14"] +radius = 0.3 + +[sub_resource type="CylinderShape3D" id="CylinderShape3D_752q2"] +radius = 0.3 + +[sub_resource type="CylinderShape3D" id="CylinderShape3D_ebbqv"] +radius = 0.3 [node name="ShotgunBullet" type="Node3D"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.73894, 0) @@ -23,7 +29,7 @@ contact_monitor = true can_sleep = false [node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D"] -shape = SubResource("SphereShape3D_o6kys") +shape = SubResource("CylinderShape3D_eme14") [node name="Sprite3D" type="Sprite3D" parent="RigidBody3D"] axis = 1 @@ -40,7 +46,7 @@ contact_monitor = true can_sleep = false [node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D2"] -shape = SubResource("SphereShape3D_o6kys") +shape = SubResource("CylinderShape3D_752q2") [node name="Sprite3D" type="Sprite3D" parent="RigidBody3D2"] axis = 1 @@ -57,7 +63,7 @@ contact_monitor = true can_sleep = false [node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D3"] -shape = SubResource("SphereShape3D_o6kys") +shape = SubResource("CylinderShape3D_ebbqv") [node name="Sprite3D" type="Sprite3D" parent="RigidBody3D3"] axis = 1 diff --git a/Scenes/TestBullet.tscn b/Scenes/TestBullet.tscn index b3ba74f..31066c7 100644 --- a/Scenes/TestBullet.tscn +++ b/Scenes/TestBullet.tscn @@ -9,8 +9,7 @@ albedo_color = Color(0.584314, 0.0352941, 0.141176, 1) [sub_resource type="SphereMesh" id="SphereMesh_wuk0e"] material = SubResource("StandardMaterial3D_phgri") -[sub_resource type="SphereShape3D" id="SphereShape3D_rokeu"] -radius = 0.2 +[sub_resource type="CylinderShape3D" id="CylinderShape3D_3c0di"] [node name="TestBullet" type="Node3D"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.538645, 0) @@ -20,7 +19,7 @@ _projectileSpeed = 15.0 [node name="RigidBody3D" type="RigidBody3D" parent="."] collision_layer = 34 -collision_mask = 32 +collision_mask = 34 gravity_scale = 0.0 continuous_cd = true max_contacts_reported = 1000 @@ -34,7 +33,7 @@ skeleton = NodePath("../..") [node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0054872, -0.00215495, 0.0167444) -shape = SubResource("SphereShape3D_rokeu") +shape = SubResource("CylinderShape3D_3c0di") [node name="Sprite3D" type="Sprite3D" parent="RigidBody3D"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00168204, -0.0587139, 0) diff --git a/Scripts/MeleeEnemy.cs b/Scripts/MeleeEnemy.cs index 836f4ea..0a17489 100644 --- a/Scripts/MeleeEnemy.cs +++ b/Scripts/MeleeEnemy.cs @@ -1,9 +1,10 @@ using Godot; using System.Linq; -public partial class MeleeEnemy : CharacterBody3D +public partial class MeleeEnemy : BasicEnemy { - private float _speed = 1.0f; + [Export] + private float _speed = 0.4f; public override void _PhysicsProcess(double delta) { @@ -12,9 +13,22 @@ public partial class MeleeEnemy : CharacterBody3D { var convertedPlayers = players.Select(x => (Node3D)x); var target = convertedPlayers.OrderBy(x => Position.DistanceTo(x.Position)).FirstOrDefault(); - GD.Print(Position.DirectionTo(target.Position)); Position = Position.MoveToward(target.Position, _speed * (float)delta); MoveAndSlide(); } } } + +public partial class BasicEnemy : CharacterBody3D +{ + public void OnHit(Node3D node) + { + QueueFree(); + } + + private void DebugOnHit() + { + var node = new Node3D(); + OnHit(node); + } +}