From e18345ab2ad3956b611c963d3ac510e17be01ffd Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 3 Oct 2020 20:53:58 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20Fix=20ScrollingBlock=20being=20p?= =?UTF-8?q?ushed=20back=20by=20the=20player?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Scenes/Obstacles/ScrollingBlock.tscn | 1 + Scripts/Obstacles/ScrollingBlock.gd | 5 +---- Scripts/Player.gd | 6 +----- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Scenes/Obstacles/ScrollingBlock.tscn b/Scenes/Obstacles/ScrollingBlock.tscn index 0bd4b9b..49a5a0c 100644 --- a/Scenes/Obstacles/ScrollingBlock.tscn +++ b/Scenes/Obstacles/ScrollingBlock.tscn @@ -9,6 +9,7 @@ extents = Vector2( 20, 20 ) [node name="ScrollingBlock" type="KinematicBody2D"] collision_layer = 8 collision_mask = 2 +motion/sync_to_physics = true script = ExtResource( 2 ) [node name="Sprite" type="Sprite" parent="."] diff --git a/Scripts/Obstacles/ScrollingBlock.gd b/Scripts/Obstacles/ScrollingBlock.gd index f70e04f..8fb17c8 100644 --- a/Scripts/Obstacles/ScrollingBlock.gd +++ b/Scripts/Obstacles/ScrollingBlock.gd @@ -6,7 +6,4 @@ export(Vector2) var scroll_velocity: Vector2 = Vector2(-10, 0) func _physics_process(delta): - # FIXME: This doesn't really work... Any other things we could try? - var collision = move_and_collide(scroll_velocity * delta) - if collision: - print(collision) + position += scroll_velocity * delta diff --git a/Scripts/Player.gd b/Scripts/Player.gd index 5c4ec6d..a7d26b0 100644 --- a/Scripts/Player.gd +++ b/Scripts/Player.gd @@ -60,8 +60,4 @@ func _physics_process(delta): if Input.is_action_pressed("plr_right"): movement += Vector2.RIGHT * move_speed - player_move(movement) - - -func player_move(movement): - move_and_slide(movement, up_normal()) + move_and_slide(movement, up_normal)