destroy the crates

This commit is contained in:
KevinGorman committed 2025-01-06 20:34:02 -05:00
1 parent e69c47ab3e
commit 2605a085e2
4 files changed
+36 -3

No files matched your search

@@ -3,6 +3,7 @@ extends CharacterBody2D
const SPEED = 500.0
const JUMP_VELOCITY = -600.0
@export var PUSH_FORCE = 90
func _physics_process(delta: float) -> void:
@@ -23,3 +24,7 @@ func _physics_process(delta: float) -> void:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
for i in (get_slide_collision_count()):
var c = get_slide_collision(i)
if c.get_collider() is RigidBody2D:
c.get_collider().apply_central_impulse(-c.get_normal()*PUSH_FORCE)
+17
View File
@@ -0,0 +1,17 @@
extends Node2D
# 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_trigger(effect: Variant, body) -> void:
print("they were triggered!")
if body is RigidBody2D:
print("crate spotted")
body.queue_free()
+4
View File
@@ -1,5 +1,7 @@
extends Area2D
@export var effect = "alert"
signal areaTrigger(effect, Object)
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@@ -13,3 +15,5 @@ func _process(delta: float) -> void:
func _on_body_entered(body: Node2D) -> void:
print("I'm triggered!")
areaTrigger.emit(effect, body)