Shoot through

This commit is contained in:
MaddoScientisto 2024-05-26 11:40:35 +02:00
commit 92a82b05df
6 changed files with 31 additions and 42 deletions

View file

@ -20,10 +20,10 @@ public partial class Bullet : Area2D
//private void OnBodyEntered(Node body)
//{
// When a body is entered, invoke the event and pass the collided body
// When a body is entered, invoke the event and pass the collided body
// BulletHit?.Invoke(body);
// Then remove the bullet
// Then remove the bullet
// QueueFree();
//}
@ -40,7 +40,7 @@ public partial class Bullet : Area2D
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
this.Position += ((float) (Speed * delta) * _direction);
this.Position += ((float)(Speed * delta) * _direction);
}
private void _on_visible_on_screen_notifier_2d_screen_exited()
@ -49,7 +49,19 @@ public partial class Bullet : Area2D
QueueFree();
}
private void _on_body_entered(Node2D body)
{
if (body.IsInGroup("Solid"))
{
Debug.WriteLine("Collision");
QueueFree();
}
}
}