Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions components/platform/platform.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ const DEFAULT_TILE_SET = preload("res://spaces/tileset-threadbare.tres")
@export var one_way: bool = false:
set = _set_one_way

@export_group("Falling Platform")

## Whether the platform should fall after the player-character touches it.
@export_custom(PROPERTY_HINT_GROUP_ENABLE, "") var fall: bool = false

## Number of seconds after touching the platform for it to fall.
## Negative values won't fall.
@export var fall_time: float = -1
## If set to [code]0[/code], the platform falls as soon as the player-character touches it.
## [br][br]
## Has no effect if [member fall] is disabled.
@export_range(0, 5, 0.1, "suffix:s", "or_greater") var fall_time: float = 2.0

var fall_timer: Timer

Expand Down Expand Up @@ -101,10 +108,14 @@ func _ready():
func _on_area_2d_body_entered(body):
if not body.is_in_group("players"):
return

if not fall:
return

if fall_time > 0:
fall_timer.start(fall_time)
_animation_player.play("shake")
elif fall_time == 0:
else:
_rigid_body.call_deferred("set_freeze_enabled", false)


Expand Down
12 changes: 6 additions & 6 deletions main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -214,37 +214,37 @@ width = 2
position = Vector2(-1472, 0)
width = 2
one_way = true
fall_time = 2.0
fall = true

[node name="Platform5" parent="Platforms" unique_id=783386559 instance=ExtResource("4_gd51l")]
position = Vector2(-1152, 0)
width = 2
one_way = true
fall_time = 2.0
fall = true

[node name="Platform6" parent="Platforms" unique_id=328079907 instance=ExtResource("4_gd51l")]
position = Vector2(-832, 0)
width = 2
one_way = true
fall_time = 2.0
fall = true

[node name="Platform7" parent="Platforms" unique_id=1586665119 instance=ExtResource("4_gd51l")]
position = Vector2(-512, 0)
width = 2
one_way = true
fall_time = 2.0
fall = true

[node name="Platform8" parent="Platforms" unique_id=1264675022 instance=ExtResource("4_gd51l")]
position = Vector2(-192, 0)
width = 2
one_way = true
fall_time = 2.0
fall = true

[node name="Platform9" parent="Platforms" unique_id=39900956 instance=ExtResource("4_gd51l")]
position = Vector2(128, 0)
width = 2
one_way = true
fall_time = 2.0
fall = true

[node name="Platform2" parent="Platforms" unique_id=16930057 instance=ExtResource("4_gd51l")]
position = Vector2(1216, -64)
Expand Down