36 lines
521 B
C#
36 lines
521 B
C#
using Godot;
|
|
|
|
public partial class ProjectileBase : Area2D
|
|
{
|
|
[Export] public float Speed { get; set; }
|
|
|
|
protected CharacterBase? Character;
|
|
|
|
public override void _Ready()
|
|
{
|
|
if (Character is null)
|
|
{
|
|
QueueFree();
|
|
}
|
|
}
|
|
|
|
void OnBodyEntered(Node body)
|
|
{
|
|
if (body == Character)
|
|
{
|
|
// Ignore self
|
|
return;
|
|
}
|
|
|
|
QueueFree();
|
|
}
|
|
|
|
public void Spawn(CharacterBase character)
|
|
{
|
|
Character = character;
|
|
Position = character.GlobalPosition;
|
|
Rotation = character.FacingRotation;
|
|
TopLevel = false;
|
|
}
|
|
}
|