mirror of
https://github.com/GDQuest/godot-platformer-2d.git
synced 2026-01-23 02:14:19 +00:00
Add instakill condition to Stats and a Fall Limit Area
Use the FallLimitArea.tscn to visually set a height in the level that will trigger an instakill. Closes: #173
This commit is contained in:
parent
c59526cd1b
commit
c88269743c
2 changed files with 20 additions and 3 deletions
|
|
@ -26,7 +26,12 @@ func _ready() -> void:
|
|||
func take_damage(hit: Hit) -> void:
|
||||
if invulnerable:
|
||||
return
|
||||
|
||||
|
||||
# Damages with value of -1 mean instakill
|
||||
if hit.damage == -1:
|
||||
emit_signal("health_depleted")
|
||||
return
|
||||
|
||||
var old_health = health
|
||||
health -= hit.damage
|
||||
emit_signal("damage_taken")
|
||||
|
|
@ -58,8 +63,8 @@ func remove_modifier(id: int) -> void:
|
|||
|
||||
func set_invulnerable_for_seconds(time: float) -> void:
|
||||
invulnerable = true
|
||||
|
||||
|
||||
var timer := get_tree().create_timer(time)
|
||||
yield(timer, "timeout")
|
||||
|
||||
|
||||
invulnerable = false
|
||||
|
|
|
|||
12
game/src/Objects/FallLimitArea.tscn
Normal file
12
game/src/Objects/FallLimitArea.tscn
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://src/Combat/DamageSource.tscn" type="PackedScene" id=1]
|
||||
|
||||
[sub_resource type="LineShape2D" id=1]
|
||||
|
||||
[node name="FallLimitArea" instance=ExtResource( 1 )]
|
||||
position = Vector2( 0, -2.93628 )
|
||||
damage = -1
|
||||
|
||||
[node name="CollisionShape2D" parent="." index="0"]
|
||||
shape = SubResource( 1 )
|
||||
Loading…
Add table
Add a link
Reference in a new issue