feat: fix the block pushing; add new groups for walls and pushable objects;
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user