[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

@@ -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");