This commit is contained in:
2023-09-11 17:42:11 -07:00
parent ba9c1e320e
commit 4d8fbda71b
21 changed files with 123 additions and 67 deletions

View File

@@ -2,12 +2,6 @@ using Godot;
public partial class EnemyBullet : Projectile
{
public override void _PhysicsProcess(double delta)
{
TranslateObjectLocal(new Vector3(0, 0, -Speed * (float)delta));
}
public new void OnProjectileHit(Node node)
{
SetPhysicsProcess(false);
@@ -15,7 +9,7 @@ public partial class EnemyBullet : Projectile
if (node is Character character && character.HasMethod(Character.MethodName.OnHit))
{
GD.Print("Player hit: " + character.Name);
character.Call(Character.MethodName.OnHit, node);
character.Call(Character.MethodName.OnHit, this);
}
QueueFree();

View File

@@ -2,22 +2,32 @@
[ext_resource type="Script" path="res://Enemies/Attacks/EnemyBullet.cs" id="1_rv13r"]
[ext_resource type="Texture2D" uid="uid://dd71tdgrgic46" path="res://Textures/Projectiles/LB ORB.png" id="2_6l2aj"]
[ext_resource type="AudioStream" uid="uid://cfj82os5p8i4p" path="res://Audio/SFX/shooting.wav" id="2_q6wdf"]
[sub_resource type="Curve3D" id="Curve3D_eve6n"]
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, -3),
"tilts": PackedFloat32Array(0, 0)
}
point_count = 2
[sub_resource type="CylinderShape3D" id="CylinderShape3D_e4v7f"]
height = 2.31583
height = 15.359
radius = 0.154574
[node name="TestBullet" type="Node3D"]
[node name="EnemyBullet" type="Path3D"]
curve = SubResource("Curve3D_eve6n")
script = ExtResource("1_rv13r")
Cooldown = 3.0
_soundEffect = ExtResource("2_q6wdf")
[node name="RigidBody3D" type="RigidBody3D" parent="."]
[node name="PathFollow3D" type="PathFollow3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
loop = false
tilt_enabled = false
[node name="RigidBody3D" type="RigidBody3D" parent="PathFollow3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0)
collision_layer = 0
collision_mask = 3
gravity_scale = 0.0
custom_integrator = true
continuous_cd = true
max_contacts_reported = 10
contact_monitor = true
@@ -26,19 +36,19 @@ lock_rotation = true
freeze = true
freeze_mode = 1
[node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="PathFollow3D/RigidBody3D"]
transform = Transform3D(0.3, 0, 0, 0, 0.3, 0, 0, 0, 0.3, 0.0111055, 1.02602, 0)
shape = SubResource("CylinderShape3D_e4v7f")
[node name="Sprite3D" type="Sprite3D" parent="RigidBody3D/CollisionShape3D"]
[node name="Sprite3D" type="Sprite3D" parent="PathFollow3D/RigidBody3D/CollisionShape3D"]
transform = Transform3D(0.08, 0, 0, 0, 0.08, 0, 0, 0, 0.08, -0.390424, 0, 0.436329)
centered = false
axis = 1
texture = ExtResource("2_6l2aj")
[node name="TTL" type="Timer" parent="."]
[node name="TTL" type="Timer" parent="PathFollow3D"]
process_callback = 0
wait_time = 0.8
autostart = true
[connection signal="body_entered" from="RigidBody3D" to="." method="OnProjectileHit"]
[connection signal="body_entered" from="PathFollow3D/RigidBody3D" to="." method="OnProjectileHit"]

View File

@@ -1178,6 +1178,8 @@ _data = {
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.251952, 0)
collision_layer = 0
collision_mask = 69
axis_lock_angular_x = true
axis_lock_angular_z = true
gravity_scale = 0.0
max_contacts_reported = 20
contact_monitor = true

View File

@@ -6,7 +6,7 @@
[ext_resource type="PackedScene" uid="uid://b1j0g6ikmnibm" path="res://Enemies/HPComponent.tscn" id="4_1vt55"]
[sub_resource type="BoxShape3D" id="BoxShape3D_dm3u7"]
size = Vector3(0.721796, 2.37333, 0.564825)
size = Vector3(0.722, 1, 0.565)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cr37n"]
resource_name = "Material.002"
@@ -895,6 +895,7 @@ shadow_mesh = SubResource("ArrayMesh_j7wsk")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.257979, 0)
collision_layer = 0
collision_mask = 69
gravity_scale = 0.0
max_contacts_reported = 20
contact_monitor = true
can_sleep = false
@@ -911,7 +912,7 @@ _fireProjectile = ExtResource("3_qenx3")
_distanceToPlayer = 5.0
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0714533, 0.795379, 0.0138905)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0714533, 0.929308, 0.0138905)
shape = SubResource("BoxShape3D_dm3u7")
[node name="ranged enemy" type="Node3D" parent="."]

View File

@@ -26,11 +26,11 @@ public partial class BasicEnemy : Node3D
public void OnPlayerHit(Node3D node)
{
GD.Print("Collision with player");
if (node is Character character && character.HasMethod(Character.MethodName.OnHit))
{
GD.Print("Collision with player at " + node.GlobalPosition + "by " + Name);
GD.Print("Player hit: " + character.Name);
character.Call(Character.MethodName.OnHit, node);
character.Call(Character.MethodName.OnHit, this);
}
}
}