mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 11:45:53 +00:00
Restored enemy bullets collision
This commit is contained in:
parent
076cff208d
commit
4e09694692
5 changed files with 34 additions and 2 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue