fix mines

This commit is contained in:
SondreElg
2025-10-05 14:31:36 +02:00
parent c3a35cb4e3
commit 4df984bc3e
2 changed files with 12 additions and 3 deletions

View File

@@ -4,17 +4,20 @@ extends Node2D
@export var knockback_strength = 4
func _on_area_entered(area: Area2D) -> void:
print_debug("Mine triggered by area: %s" % area)
if self.get_parent().is_in_group("Virus"):
# Prevent friendly fire
return
if area.name != "Hurtbox":
return
var area_parent = area.get_parent()
if (area_parent.is_in_group("Virus")):
area_parent.take_hit(damage, self.position.direction_to(area.position) * 50, knockback_strength)
area_parent.take_hit(damage, self.position.direction_to(area.position) * 200, knockback_strength)
func _on_body_entered(body):
if self.get_parent() == body:
return
body.take_hit(damage, self.position.direction_to(body.position) * 50, knockback_strength)
body.take_hit(damage, self.position.direction_to(body.position) * 200, knockback_strength)
func _on_timer_timeout():

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=5 format=3 uid="uid://umv7m1lf4x6b"]
[gd_scene load_steps=6 format=3 uid="uid://umv7m1lf4x6b"]
[ext_resource type="Script" uid="uid://b3jims0gq4tg5" path="res://CardInjects/Mine/mine.gd" id="1_mj2xh"]
[ext_resource type="Texture2D" uid="uid://dmq8shsoq55dx" path="res://assets/icons/Mine_symbol.png" id="2_80s1i"]
@@ -23,6 +23,9 @@ void fragment() {
[sub_resource type="ShaderMaterial" id="ShaderMaterial_56tnn"]
shader = SubResource("Shader_80s1i")
[sub_resource type="CircleShape2D" id="CircleShape2D_80s1i"]
radius = 135
[node name="Mine" type="Node2D"]
script = ExtResource("1_mj2xh")
@@ -33,9 +36,12 @@ texture = ExtResource("2_80s1i")
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("CircleShape2D_80s1i")
[node name="Timer" type="Timer" parent="."]
one_shot = true
autostart = true
[connection signal="area_entered" from="Area2D" to="." method="_on_area_entered"]
[connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"]
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]