feat: fix the block pushing; add new groups for walls and pushable objects;

This commit is contained in:
2026-09-18 10:39:03 +02:00
parent 8ba607d1b0
commit 2b4b54612f
5 changed files with 13 additions and 5 deletions
+3 -3
View File
@@ -3,6 +3,7 @@ class_name Player
@export var move_speed: float = 100
@export var hp: int = 10
@export var push_strength: int = 50
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@@ -33,10 +34,9 @@ func _process(delta: float) -> void:
var collision: KinematicCollision2D = get_last_slide_collision()
if collision:
var collisision_node = collision.get_collider()
if collisision_node is RigidBody2D:
if collisision_node.is_in_group("pushable"):
var collision_normal: Vector2 = collision.get_normal()
collisision_node.apply_central_force(-collision_normal)
collisision_node.apply_central_force(-collision_normal * push_strength)
move_and_slide()