Fix capricorn projectile bug

This commit is contained in:
2023-09-08 12:46:23 -07:00
parent 9256c0a09e
commit f7008b40ff
21 changed files with 161 additions and 279 deletions

View File

@@ -88,6 +88,11 @@ public partial class Character : CharacterBody3D
projectile.Position = Position;
GetParent().AddChild(projectile);
var projectiles = projectile.GetChildren().OfType<Projectile>();
foreach (var proj in projectiles)
{
if (proj.HasRotation)
proj.Rotation = GetNode<Node3D>("Pivot").Rotation;
}
CanShoot = false;
await ToSignal(GetTree().CreateTimer(projectiles.First().Cooldown), "timeout");
CanShoot = true;

View File

@@ -32,15 +32,18 @@ public partial class Projectile : Node3D
{
var pathFollow = GetNode<PathFollow3D>("PathFollow3D");
pathFollow.Progress += Speed * (float)delta;
if (pathFollow.ProgressRatio > 0.9f)
if (pathFollow.ProgressRatio > 0.98f)
QueueFree();
}
public void OnProjectileHit(Node node)
{
SetProcess(false);
if (node.GetParent() is BasicEnemy basicEnemy && basicEnemy.HasMethod(BasicEnemy.MethodName.OnEnemyHit))
if (node is BasicEnemy basicEnemy && basicEnemy.HasMethod(BasicEnemy.MethodName.OnEnemyHit))
{
basicEnemy.Call(BasicEnemy.MethodName.OnEnemyHit, node);
GD.Print("Hit enemy at " + basicEnemy.Position);
}
else
GD.Print("Hit something other than enemy: " + node.Name);

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=8 format=3 uid="uid://5ce7ky4o0q2e"]
[gd_scene load_steps=9 format=3 uid="uid://5ce7ky4o0q2e"]
[ext_resource type="Texture2D" uid="uid://dha44dnvwhajo" path="res://Textures/Projectiles/Projectile_Capricorn.png" id="1_bvyt4"]
[ext_resource type="Script" path="res://Player/Base/Projectile.cs" id="1_ovnwu"]
@@ -12,9 +12,9 @@ _data = {
}
point_count = 2
[sub_resource type="CylinderShape3D" id="CylinderShape3D_hebl4"]
height = 44.0041
radius = 0.419241
[sub_resource type="CylinderShape3D" id="CylinderShape3D_u10le"]
height = 44.0
radius = 0.3
[sub_resource type="Curve3D" id="Curve3D_ciqkc"]
_data = {
@@ -23,10 +23,13 @@ _data = {
}
point_count = 2
[node name="CapricornAlt" type="Node3D"]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0)
[sub_resource type="CylinderShape3D" id="CylinderShape3D_1gok4"]
height = 44.0
radius = 0.3
[node name="Left Shot" type="Path3D" parent="."]
[node name="Capricorn Laser" type="Node3D"]
[node name="Forward Shot" type="Path3D" parent="." node_paths=PackedStringArray("_hitBox")]
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0.105376, 0.772365, 1.51984)
top_level = true
curve = SubResource("Curve3D_bch55")
@@ -35,34 +38,32 @@ Cooldown = 1.0
_projectileSpeed = 5.0
_soundEffect = ExtResource("2_lofnw")
_onHitSfx = ExtResource("3_h1ve3")
_hitBox = NodePath("PathFollow3D/Hitbox")
[node name="PathFollow3D" type="PathFollow3D" parent="Left Shot"]
[node name="PathFollow3D" type="PathFollow3D" parent="Forward Shot"]
transform = Transform3D(0.999997, 0, -0.00207308, 0, 1, 0, 0.00207308, 0, 0.999997, -0.00347188, 1, 0.533723)
loop = false
tilt_enabled = false
[node name="Hitbox" type="RigidBody3D" parent="Left Shot/PathFollow3D"]
transform = Transform3D(1, 0, -1.86265e-09, 0, 1, 0, 1.86265e-09, 0, 1, -0.00244793, 0.0059973, 0.293898)
collision_layer = 4
collision_mask = 0
[node name="Hitbox" type="RigidBody3D" parent="Forward Shot/PathFollow3D"]
collision_layer = 12
gravity_scale = 0.0
continuous_cd = true
max_contacts_reported = 1
contact_monitor = true
can_sleep = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="Left Shot/PathFollow3D/Hitbox"]
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0)
shape = SubResource("CylinderShape3D_hebl4")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Forward Shot/PathFollow3D/Hitbox"]
shape = SubResource("CylinderShape3D_u10le")
[node name="Sprite3D2" type="Sprite3D" parent="Left Shot/PathFollow3D/Hitbox/CollisionShape3D"]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, -0.663415, 0, 0.752893)
[node name="Sprite3D2" type="Sprite3D" parent="Forward Shot/PathFollow3D/Hitbox/CollisionShape3D"]
transform = Transform3D(1, 0, 1.42109e-14, 0, 1, 0, -1.42109e-14, 0, 1, -0.32341, 0, 0.371708)
centered = false
axis = 1
texture = ExtResource("1_bvyt4")
[node name="Backward Shot" type="Path3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.098024, 0.772365, -2.01984)
[node name="Backward Shot" type="Path3D" parent="." node_paths=PackedStringArray("_hitBox")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.13167, 0.772365, -1.69199)
top_level = true
curve = SubResource("Curve3D_ciqkc")
script = ExtResource("1_ovnwu")
@@ -70,6 +71,7 @@ Cooldown = 1.0
_projectileSpeed = 5.0
_soundEffect = ExtResource("2_lofnw")
_onHitSfx = ExtResource("3_h1ve3")
_hitBox = NodePath("PathFollow3D/Hitbox")
[node name="PathFollow3D" type="PathFollow3D" parent="Backward Shot"]
transform = Transform3D(0.999997, 0, -0.00207308, 0, 1, 0, 0.00207308, 0, 0.999997, -0.00347188, 1, 0.533723)
@@ -77,9 +79,7 @@ loop = false
tilt_enabled = false
[node name="Hitbox" type="RigidBody3D" parent="Backward Shot/PathFollow3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.000400023, 0.00831366, 0.5)
collision_layer = 4
collision_mask = 0
collision_layer = 12
gravity_scale = 0.0
continuous_cd = true
max_contacts_reported = 1
@@ -87,14 +87,13 @@ contact_monitor = true
can_sleep = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="Backward Shot/PathFollow3D/Hitbox"]
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0)
shape = SubResource("CylinderShape3D_hebl4")
shape = SubResource("CylinderShape3D_1gok4")
[node name="Sprite3D2" type="Sprite3D" parent="Backward Shot/PathFollow3D/Hitbox"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.33, 0, 0.5)
[node name="Sprite3D2" type="Sprite3D" parent="Backward Shot/PathFollow3D/Hitbox/CollisionShape3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.324293, 0, 0.3549)
centered = false
axis = 1
texture = ExtResource("1_bvyt4")
[connection signal="body_entered" from="Left Shot/PathFollow3D/Hitbox" to="Left Shot" method="OnProjectileHit" flags=18]
[connection signal="body_entered" from="Backward Shot/PathFollow3D/Hitbox" to="Left Shot" method="OnProjectileHit" flags=18]
[connection signal="body_entered" from="Forward Shot/PathFollow3D/Hitbox" to="Forward Shot" method="OnProjectileHit"]
[connection signal="body_entered" from="Backward Shot/PathFollow3D/Hitbox" to="Backward Shot" method="OnProjectileHit"]

View File

@@ -1,102 +1,101 @@
[gd_scene load_steps=8 format=3 uid="uid://cdsc35cj566q1"]
[gd_scene load_steps=9 format=3 uid="uid://cdsc35cj566q1"]
[ext_resource type="Script" path="res://Player/Base/Projectile.cs" id="1_tbx8y"]
[ext_resource type="Texture2D" uid="uid://dha44dnvwhajo" path="res://Textures/Projectiles/Projectile_Capricorn.png" id="2_8osg4"]
[ext_resource type="AudioStream" uid="uid://bykwwct1not4e" path="res://Audio/SFX/capricorn laeser.wav" id="2_jeoco"]
[ext_resource type="AudioStream" uid="uid://cat08h84wm5gm" path="res://Audio/SFX/ominous.wav" id="3_r2jj5"]
[sub_resource type="Curve3D" id="Curve3D_usgyk"]
[sub_resource type="Curve3D" id="Curve3D_bch55"]
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, -0.00347188, 1, 0.533723, 0, 0, 0, 0, 0, 0, 0.008, 1, -5),
"tilts": PackedFloat32Array(0, 0)
}
point_count = 2
[sub_resource type="CylinderShape3D" id="CylinderShape3D_hebl4"]
height = 44.0041
radius = 0.419241
[sub_resource type="CylinderShape3D" id="CylinderShape3D_u10le"]
height = 44.0
radius = 0.3
[sub_resource type="Curve3D" id="Curve3D_p2eme"]
[sub_resource type="Curve3D" id="Curve3D_ciqkc"]
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, -0.00347188, 1, 0.533723, 0, 0, 0, 0, 0, 0, 0.008, 1, -5),
"tilts": PackedFloat32Array(0, 0)
}
point_count = 2
[node name="CapricornLaser" type="Node3D"]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0)
[sub_resource type="CylinderShape3D" id="CylinderShape3D_1gok4"]
height = 44.0
radius = 0.3
[node name="Left Shot" type="Path3D" parent="." node_paths=PackedStringArray("_hitBox")]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -1.66814, 0.772365, -0.25)
[node name="Capricorn Laser Alt" type="Node3D"]
[node name="Forward Shot" type="Path3D" parent="." node_paths=PackedStringArray("_hitBox")]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -1.5, 1, 0)
top_level = true
curve = SubResource("Curve3D_usgyk")
curve = SubResource("Curve3D_bch55")
script = ExtResource("1_tbx8y")
Cooldown = 1.0
_projectileSpeed = 5.0
_soundEffect = ExtResource("2_jeoco")
_onHitSfx = ExtResource("3_r2jj5")
_hitBox = NodePath("PathFollow3D/Hitbox")
_hitBox = NodePath("PathFollow3D/HitBox")
[node name="PathFollow3D" type="PathFollow3D" parent="Left Shot"]
[node name="PathFollow3D" type="PathFollow3D" parent="Forward Shot"]
transform = Transform3D(0.999997, 0, -0.00207308, 0, 1, 0, 0.00207308, 0, 0.999997, -0.00347188, 1, 0.533723)
loop = false
tilt_enabled = false
[node name="Hitbox" type="RigidBody3D" parent="Left Shot/PathFollow3D"]
transform = Transform3D(1, 0, -1.86265e-09, 0, 1, 0, 1.86265e-09, 0, 1, -0.00244793, 0.0059973, 0.293898)
collision_layer = 0
collision_mask = 0
[node name="HitBox" type="RigidBody3D" parent="Forward Shot/PathFollow3D"]
collision_layer = 12
gravity_scale = 0.0
continuous_cd = true
max_contacts_reported = 1
contact_monitor = true
can_sleep = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="Left Shot/PathFollow3D/Hitbox"]
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0)
shape = SubResource("CylinderShape3D_hebl4")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Forward Shot/PathFollow3D/HitBox"]
shape = SubResource("CylinderShape3D_u10le")
[node name="Sprite3D2" type="Sprite3D" parent="Left Shot/PathFollow3D/Hitbox/CollisionShape3D"]
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, -0.663415, 0, 0.752893)
[node name="Sprite3D2" type="Sprite3D" parent="Forward Shot/PathFollow3D/HitBox/CollisionShape3D"]
transform = Transform3D(1, 0, 1.42109e-14, 0, 1, 0, -1.42109e-14, 0, 1, -0.32341, 0, 0.371708)
centered = false
axis = 1
texture = ExtResource("2_8osg4")
[node name="Backward Shot" type="Path3D" parent="." node_paths=PackedStringArray("_hitBox")]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 1.87154, 0.772365, -0.25)
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 1.5, 1, 0)
top_level = true
curve = SubResource("Curve3D_p2eme")
curve = SubResource("Curve3D_ciqkc")
script = ExtResource("1_tbx8y")
Cooldown = 1.0
_projectileSpeed = 5.0
_soundEffect = ExtResource("2_jeoco")
_onHitSfx = ExtResource("3_r2jj5")
_hitBox = NodePath("../Left Shot/PathFollow3D/Hitbox")
_hitBox = NodePath("PathFollow3D/HitBox")
[node name="PathFollow3D" type="PathFollow3D" parent="Backward Shot"]
transform = Transform3D(0.999997, 0, -0.00207308, 0, 1, 0, 0.00207308, 0, 0.999997, -0.00347188, 1, 0.533723)
loop = false
tilt_enabled = false
[node name="Hitbox" type="RigidBody3D" parent="Backward Shot/PathFollow3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.000400023, 0.00831366, 0.5)
collision_layer = 0
collision_mask = 0
[node name="HitBox" type="RigidBody3D" parent="Backward Shot/PathFollow3D"]
transform = Transform3D(0.999999, 0, 0.00207308, 0, 1, 0, -0.00207308, 0, 0.999999, 0.00236542, -1, -0.53373)
collision_layer = 12
gravity_scale = 0.0
continuous_cd = true
max_contacts_reported = 1
contact_monitor = true
can_sleep = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="Backward Shot/PathFollow3D/Hitbox"]
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0)
shape = SubResource("CylinderShape3D_hebl4")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Backward Shot/PathFollow3D/HitBox"]
transform = Transform3D(0.999997, 0, -0.00207308, 0, 1, 0, 0.00207308, 0, 0.999997, -0.00347188, 1, 0.533723)
shape = SubResource("CylinderShape3D_1gok4")
[node name="Sprite3D2" type="Sprite3D" parent="Backward Shot/PathFollow3D/Hitbox"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.33, 0, 0.5)
[node name="Sprite3D2" type="Sprite3D" parent="Backward Shot/PathFollow3D/HitBox/CollisionShape3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.324293, 0, 0.3549)
centered = false
axis = 1
texture = ExtResource("2_8osg4")
[connection signal="body_entered" from="Left Shot/PathFollow3D/Hitbox" to="Left Shot" method="OnProjectileHit"]
[connection signal="body_entered" from="Backward Shot/PathFollow3D/Hitbox" to="Left Shot" method="OnProjectileHit"]
[connection signal="body_entered" from="Forward Shot/PathFollow3D/HitBox" to="Forward Shot" method="OnProjectileHit"]
[connection signal="body_entered" from="Backward Shot/PathFollow3D/HitBox" to="Forward Shot" method="OnProjectileHit"]

View File

@@ -219,9 +219,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.408962, 0)
collision_layer = 2
motion_mode = 1
script = ExtResource("1_aqn5t")
_fireProjectile = ExtResource("3_wbhxk")
_altFireProjectile = ExtResource("2_e6qos")
_speed = 1.0
_fireProjectile = ExtResource("2_e6qos")
_altFireProjectile = ExtResource("3_wbhxk")
_speed = 1.5
[node name="Pivot" type="Node3D" parent="."]

View File

@@ -25,9 +25,9 @@ public partial class CapricornControls : Character
GetTree().Quit();
if (Input.IsActionJustPressed(OwnerPlayer.PlayerInput.Fire()) && CanShoot)
Fire(_fireProjectile);
Fire();
if (Input.IsActionJustPressed(OwnerPlayer.PlayerInput.AltFire()) && CanShoot)
Fire(_altFireProjectile);
AltFire();
}
private Vector3 CalculateCharacterMovement(double delta)
@@ -81,13 +81,24 @@ public partial class CapricornControls : Character
_sprite.Play("WalkBack");
}
private async void Fire(PackedScene projectileScene)
private async void Fire()
{
IsShooting = true;
CanShoot = false;
var projectile = projectileScene.Instantiate<Node3D>();
var projectileCooldown = projectile.GetChildren().OfType<Projectile>().First();
await ToSignal(GetTree().CreateTimer(projectileCooldown.Cooldown), "timeout");
await ToSignal(GetTree().CreateTimer(1.0f), "timeout");
var projectile = _fireProjectile.Instantiate<Node3D>();
projectile.Position = Position;
GetParent().AddChild(projectile);
CanShoot = true;
IsShooting = false;
}
private async void AltFire()
{
IsShooting = true;
CanShoot = false;
await ToSignal(GetTree().CreateTimer(1.0f), "timeout");
var projectile = _altFireProjectile.Instantiate<Node3D>();
projectile.Position = Position;
GetParent().AddChild(projectile);
CanShoot = true;

View File

@@ -37,8 +37,7 @@ tilt_enabled = false
[node name="Hitbox" type="RigidBody3D" parent="Center Shot/PathFollow3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00512208, 0, 0.096)
collision_layer = 4
collision_mask = 0
collision_layer = 12
gravity_scale = 0.0
continuous_cd = true
max_contacts_reported = 1000
@@ -71,8 +70,7 @@ tilt_enabled = false
[node name="Hitbox" type="RigidBody3D" parent="Left Shot/PathFollow3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.03827, 0, 0.0309103)
collision_layer = 4
collision_mask = 0
collision_layer = 12
gravity_scale = 0.0
continuous_cd = true
max_contacts_reported = 1000
@@ -105,8 +103,7 @@ tilt_enabled = false
[node name="Hitbox" type="RigidBody3D" parent="Right Shot/PathFollow3D"]
transform = Transform3D(-1, 0, -0.00159994, 0, 1, 0, 0.00159994, 0, -1, -0.06, 0, 0.096)
collision_layer = 4
collision_mask = 0
collision_layer = 12
gravity_scale = 0.0
continuous_cd = true
max_contacts_reported = 1000

View File

@@ -35,8 +35,7 @@ loop = false
tilt_enabled = false
[node name="Hitbox" type="RigidBody3D" parent="Center Shot/PathFollow3D"]
collision_layer = 4
collision_mask = 0
collision_layer = 12
gravity_scale = 0.0
continuous_cd = true
max_contacts_reported = 1

View File

@@ -1,10 +0,0 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://oumrfd17ec03"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_kfsqs"]
[resource]
resource_name = "Material.005"
next_pass = SubResource("ShaderMaterial_kfsqs")
cull_mode = 2
vertex_color_use_as_albedo = true
albedo_color = Color(0.534363, 0.329744, 0.899993, 1)

View File

@@ -36,8 +36,7 @@ tilt_enabled = false
[node name="Beam" type="RigidBody3D" parent="Path3D/PathFollow3D"]
transform = Transform3D(-1, 0, -8.74229e-08, 0, 1, 0, 8.74229e-08, 0, -1, 0, 0, 0)
collision_layer = 4
collision_mask = 0
collision_layer = 12
gravity_scale = 0.0
continuous_cd = true
max_contacts_reported = 1000

View File

@@ -35,8 +35,7 @@ tilt_enabled = false
[node name="RigidBody3D" type="RigidBody3D" parent="Path3D/PathFollow3D"]
transform = Transform3D(1, 0, 2.98023e-08, 0, 1, 0, -2.98023e-08, 0, 1, 0, 0, 0)
collision_layer = 4
collision_mask = 0
collision_layer = 12
gravity_scale = 0.0
continuous_cd = true
max_contacts_reported = 100

View File

@@ -35,8 +35,7 @@ tilt_enabled = false
[node name="RigidBody3D" type="RigidBody3D" parent="CutterShot/PathFollow3D"]
transform = Transform3D(1, 0, -2.98023e-08, 0, 1, 0, 2.98023e-08, 0, 1, 0, 0, 0)
collision_layer = 4
collision_mask = 0
collision_layer = 12
gravity_scale = 0.0
continuous_cd = true
max_contacts_reported = 100