[Call of Duty noise] shotgun unlocked

This commit is contained in:
2023-09-02 02:06:16 -07:00
parent de037da23b
commit 8d5ca74330
8 changed files with 109 additions and 14 deletions

View File

@@ -3,4 +3,7 @@
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup>
<ItemGroup>
<Folder Include="Scenes\" />
</ItemGroup>
</Project>

66
Scenes/ShotgunBullet.tscn Normal file
View File

@@ -0,0 +1,66 @@
[gd_scene load_steps=5 format=3 uid="uid://bq40xbqibrk1y"]
[ext_resource type="Script" path="res://Scripts/ShotgunBullet.cs" id="1_binxs"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_5vpcx"]
albedo_color = Color(0.584314, 0.0352941, 0.141176, 1)
[sub_resource type="SphereMesh" id="SphereMesh_ugmuv"]
material = SubResource("StandardMaterial3D_5vpcx")
[sub_resource type="SphereShape3D" id="SphereShape3D_o6kys"]
[node name="ShotgunBullet" type="Node3D"]
script = ExtResource("1_binxs")
_projectileSpeed = 5.0
[node name="RigidBody3D" type="RigidBody3D" parent="."]
transform = Transform3D(0.999848, 0, -0.0174524, 0, 1, 0, 0.0174524, 0, 0.999848, -0.275608, 0, 0)
collision_layer = 2
collision_mask = 0
gravity_scale = 0.0
continuous_cd = true
contact_monitor = true
[node name="MeshInstance3D" type="MeshInstance3D" parent="RigidBody3D"]
transform = Transform3D(0.0647894, 0, 0.0761731, 0, 0.1, 0, -0.0761731, 0, 0.0647894, 0, 0, 0)
mesh = SubResource("SphereMesh_ugmuv")
skeleton = NodePath("../..")
[node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D"]
transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0)
shape = SubResource("SphereShape3D_o6kys")
[node name="RigidBody3D2" type="RigidBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.207104)
collision_layer = 2
collision_mask = 0
gravity_scale = 0.0
continuous_cd = true
contact_monitor = true
[node name="MeshInstance3D" type="MeshInstance3D" parent="RigidBody3D2"]
transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0)
mesh = SubResource("SphereMesh_ugmuv")
skeleton = NodePath("../..")
[node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D2"]
transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0)
shape = SubResource("SphereShape3D_o6kys")
[node name="RigidBody3D3" type="RigidBody3D" parent="."]
transform = Transform3D(0.999848, 0, 0.0174524, 0, 1, 0, -0.0174524, 0, 0.999848, 0.226111, 0, 0)
collision_layer = 2
collision_mask = 0
gravity_scale = 0.0
continuous_cd = true
contact_monitor = true
[node name="MeshInstance3D" type="MeshInstance3D" parent="RigidBody3D3"]
transform = Transform3D(0.0906308, 0, -0.0422618, 0, 0.1, 0, 0.0422618, 0, 0.0906308, 0, 0, 0)
mesh = SubResource("SphereMesh_ugmuv")
skeleton = NodePath("../..")
[node name="CollisionShape3D" type="CollisionShape3D" parent="RigidBody3D3"]
transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0)
shape = SubResource("SphereShape3D_o6kys")

View File

@@ -2,11 +2,11 @@
[ext_resource type="Script" path="res://Scripts/TestBullet.cs" id="1_cavby"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_5vpcx"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_phgri"]
albedo_color = Color(0.584314, 0.0352941, 0.141176, 1)
[sub_resource type="SphereMesh" id="SphereMesh_wuk0e"]
material = SubResource("StandardMaterial3D_5vpcx")
material = SubResource("StandardMaterial3D_phgri")
[sub_resource type="SphereShape3D" id="SphereShape3D_rokeu"]
@@ -15,7 +15,8 @@ script = ExtResource("1_cavby")
_projectileSpeed = 5.0
[node name="RigidBody3D" type="RigidBody3D" parent="."]
collision_layer = 0
collision_layer = 2
collision_mask = 0
gravity_scale = 0.0
continuous_cd = true
contact_monitor = true

View File

@@ -1,7 +1,8 @@
[gd_scene load_steps=5 format=3 uid="uid://b38hcomu4tpm5"]
[gd_scene load_steps=6 format=3 uid="uid://b38hcomu4tpm5"]
[ext_resource type="Script" path="res://Scripts/TestCharacter.cs" id="1_hddqi"]
[ext_resource type="PackedScene" uid="uid://dtyujwnb6w3kv" path="res://Models/TestModels/link.gltf" id="1_rwdbt"]
[ext_resource type="PackedScene" uid="uid://bq40xbqibrk1y" path="res://Scenes/ShotgunBullet.tscn" id="3_5h4r7"]
[ext_resource type="PackedScene" uid="uid://si4byubqnng4" path="res://Scenes/TestBullet.tscn" id="3_ojvu2"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_fqik1"]
@@ -11,7 +12,8 @@ height = 0.456443
[node name="Character" type="CharacterBody3D"]
script = ExtResource("1_hddqi")
_speed = 2.0
_attackPattern = ExtResource("3_ojvu2")
_fireProjectile = ExtResource("3_ojvu2")
_altFireProjectile = ExtResource("3_5h4r7")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(0.999665, -0.0258978, -7.10543e-15, 0.0258978, 0.999665, 0, 0, 0, 1, 0, 0.19703, 0)

View File

@@ -10,6 +10,10 @@ size = Vector3(100, 1, 100)
[node name="Level" type="Node3D"]
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.118128, 8.18686, -1.13346)
fov = 40.0
[node name="StaticBody3D" type="StaticBody3D" parent="."]
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
@@ -18,11 +22,7 @@ shape = SubResource("BoxShape3D_dk0pn")
[node name="MeshInstance3D" type="MeshInstance3D" parent="StaticBody3D"]
mesh = SubResource("BoxMesh_eaper")
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.118128, 8.18686, -1.13346)
fov = 40.0
[node name="DebugCamera" type="Camera3D" parent="."]
[node name="DebugCamera" type="Camera3D" parent="StaticBody3D"]
transform = Transform3D(1, 0, 0, 0, 0.821149, 0.570714, 0, -0.570714, 0.821149, -0.36148, 1.40359, 0.864433)
visible = false

13
Scripts/ShotgunBullet.cs Normal file
View File

@@ -0,0 +1,13 @@
using Godot;
using System.Linq;
public partial class ShotgunBullet : Projectile
{
public override void _PhysicsProcess(double delta)
{
var pellets = GetChildren().OfType<RigidBody3D>();
foreach (var pellet in pellets)
pellet.Translate(new Vector3(pellet.Rotation.Y, 0, Speed * -(float)delta));
}
}

View File

@@ -6,5 +6,4 @@ public partial class TestBullet : Projectile
{
Translate(new Vector3(0, 0, Speed * -(float)delta));
}
}

View File

@@ -5,12 +5,16 @@ public partial class TestCharacter : CharacterBody3D
[Export]
private float _speed = 5.0f;
[Export]
private PackedScene _attackPattern;
private PackedScene _fireProjectile;
[Export]
private PackedScene _altFireProjectile;
public override void _PhysicsProcess(double delta)
{
if (Input.IsActionJustPressed("p1_fire"))
Fire();
if (Input.IsActionJustPressed("p1_altfire"))
AltFire();
Velocity = CalculateCharacterMovement();
MoveAndSlide();
@@ -37,8 +41,15 @@ public partial class TestCharacter : CharacterBody3D
private async void Fire()
{
GD.Print("Shoot");
var projectile = _attackPattern.Instantiate<Projectile>();
var projectile = _fireProjectile.Instantiate<Projectile>();
projectile.Position = Position + new Vector3(0f, 0f, -0.2f);
GetParent().AddChild(projectile);
await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout");
}
private async void AltFire()
{
var projectile = _altFireProjectile.Instantiate<Projectile>();
projectile.Position = Position + new Vector3(0f, 0f, -0.2f);
GetParent().AddChild(projectile);
await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout");