war and murder
This commit is contained in:
11
Scripts/EnemyBullet.cs
Normal file
11
Scripts/EnemyBullet.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Godot;
|
||||
|
||||
public partial class EnemyBullet : Projectile
|
||||
{
|
||||
public Vector3 Target;
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
Translate(new Vector3(0, 0, -Speed * (float)delta));
|
||||
}
|
||||
}
|
||||
23
Scripts/FireAtPlayer.cs
Normal file
23
Scripts/FireAtPlayer.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Godot;
|
||||
|
||||
public partial class FireAtPlayer : Timer
|
||||
{
|
||||
[Export]
|
||||
private Node3D _enemy;
|
||||
[Export]
|
||||
private PackedScene _fireProjectile;
|
||||
|
||||
public void OnFireAtPlayer()
|
||||
{
|
||||
GD.Print("Fire at player");
|
||||
var projectile = _fireProjectile.Instantiate<Projectile>() as EnemyBullet;
|
||||
projectile.Rotation = _enemy.Rotation;
|
||||
projectile.Position = _enemy.Position;
|
||||
GetParent().AddChild(projectile);
|
||||
}
|
||||
|
||||
private void OnDied()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
@@ -66,4 +66,9 @@ public partial class TestCharacter : CharacterBody3D
|
||||
await ToSignal(GetTree().CreateTimer(projectile.Cooldown), "timeout");
|
||||
CanShoot = true;
|
||||
}
|
||||
|
||||
private void OnHit(Node3D node)
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user