Restored enemy bullets collision

This commit is contained in:
Marco 2025-01-31 16:06:15 +01:00
commit 4e09694692
5 changed files with 34 additions and 2 deletions

View file

@ -9,6 +9,9 @@ public partial class Bullet : Area2D
[Export]
public float Damage = 1f;
[Export]
public BulletOwner Owner = BulletOwner.None;
private Vector2 _direction = Vector2.Right;
@ -87,3 +90,10 @@ public partial class Bullet : Area2D
}
}
}
public enum BulletOwner
{
None,
Player,
Enemy
}

View file

@ -3,7 +3,7 @@ using Godot;
using System;
using System.Diagnostics;
public partial class Enemy : CharacterBody2D, IDestructible
public partial class Enemy : CharacterBody2D
{
private InteractionController _cachedPlayer;
private EnemyState _currentState = EnemyState.Idle;
@ -190,6 +190,14 @@ public partial class Enemy : CharacterBody2D, IDestructible
_currentState = EnemyState.Idle;
}
}
private void _on_damage_hitbox_area_entered(Area2D area)
{
if (area is not Bullet bullet) return;
GD.Print("Enemy Received damage");
this.Hit(bullet.Damage);
bullet.QueueFree();
}
// Bullets collision
private void _on_area_entered(Area2D area)