1.1/Add trap
This commit is contained in:
@@ -3,7 +3,7 @@ extends CharacterBody3D
|
||||
|
||||
const SPEED:= 300.0
|
||||
const JUMP_VELOCITY:= 10.0
|
||||
|
||||
var Executed = false
|
||||
|
||||
@onready var animator = get_node("gobot_new/AnimationPlayer")
|
||||
@onready var hud_container: HBoxContainer = $hud/Hud_container
|
||||
@@ -29,10 +29,7 @@ var is_dead := false
|
||||
|
||||
|
||||
|
||||
func verfy_life():
|
||||
if health == 0:
|
||||
is_dead = true
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -122,6 +119,15 @@ func collect_coin():
|
||||
coins += 1
|
||||
hud_container.update_coin(coins)
|
||||
|
||||
func damage_player(amount: int):
|
||||
health -= amount
|
||||
verfy_life()
|
||||
func damage(amount: int):
|
||||
if not Executed:
|
||||
health -= amount
|
||||
verify_life()
|
||||
Executed = true
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
Executed = false
|
||||
|
||||
func verify_life():
|
||||
if health == 0:
|
||||
is_dead = true
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
extends MeshInstance3D
|
||||
|
||||
@export var damage_trap := 1
|
||||
var Execute:= false
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_area_3d_body_entered(body: Node3D) -> void:
|
||||
while Execute ==false:
|
||||
body.damage(damage_trap)
|
||||
Execute = true
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
Execute = false
|
||||
@@ -0,0 +1 @@
|
||||
uid://cyf2dpymwq3qh
|
||||
@@ -0,0 +1,16 @@
|
||||
extends MeshInstance3D
|
||||
|
||||
var dead:= false
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_area_3d_body_entered(body: Node3D) -> void:
|
||||
print(body.name)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://by3rc8i42d8iu
|
||||
Reference in New Issue
Block a user