falling block has a delay before falling
This commit is contained in:
parent
124b5e16aa
commit
c3f32de2df
7 changed files with 216 additions and 40 deletions
|
@ -25,7 +25,6 @@ func _physics_process(delta):
|
|||
else: move_up_and_down(delta)
|
||||
#Speed up if in raycast
|
||||
if raycast.get_collider() != null:
|
||||
Debug.print(raycast.get_collider())
|
||||
if raycast.get_collider().is_in_group("player"):
|
||||
go_fast = true
|
||||
timer.set_wait_time(0.5)
|
||||
|
|
|
@ -38,7 +38,6 @@ move_speed = 50.0
|
|||
material = SubResource( 5 )
|
||||
position = Vector2( 0, 1 )
|
||||
frames = SubResource( 3 )
|
||||
frame = 1
|
||||
playing = true
|
||||
|
||||
[node name="Hitbox" type="Area2D" parent="." index="1"]
|
||||
|
|
|
@ -3,16 +3,27 @@ extends KinematicBody2D
|
|||
var fall = false
|
||||
export var fall_speed = 0.5
|
||||
onready var startpos = position
|
||||
onready var timer = $Timer
|
||||
|
||||
func _physics_process(delta):
|
||||
if fall:
|
||||
position.y += fall_speed
|
||||
Debug.print($Timer.get_time_left())
|
||||
|
||||
func _on_Area2D_area_entered(area):
|
||||
if area.is_in_group("player"):
|
||||
fall = true
|
||||
$Timer.start()
|
||||
|
||||
|
||||
func _on_VisibilityNotifier2D_screen_exited():
|
||||
position = startpos
|
||||
fall = false
|
||||
|
||||
|
||||
func _on_Timer_timeout():
|
||||
fall = true
|
||||
|
||||
|
||||
func _on_Area2D_area_exited(area):
|
||||
$Timer.stop()
|
||||
|
||||
|
|
|
@ -35,5 +35,11 @@ collision_mask = 2
|
|||
position = Vector2( 4, -0.5 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
wait_time = 0.15
|
||||
one_shot = true
|
||||
|
||||
[connection signal="screen_exited" from="VisibilityNotifier2D" to="." method="_on_VisibilityNotifier2D_screen_exited"]
|
||||
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]
|
||||
[connection signal="area_exited" from="Area2D" to="." method="_on_Area2D_area_exited"]
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||
|
|
|
@ -21,19 +21,20 @@ script = ExtResource( 3 )
|
|||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
material = SubResource( 1 )
|
||||
position = Vector2( 0, -1 )
|
||||
position = Vector2( -1, -1 )
|
||||
texture = ExtResource( 1 )
|
||||
centered = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 5, 3.5 )
|
||||
position = Vector2( 4, 3.5 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." groups=["squash"]]
|
||||
position = Vector2( -1, 0 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2( 5, 3.5 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="Bottom" type="Position2D" parent="."]
|
||||
position = Vector2( 5, 8 )
|
||||
position = Vector2( 4, 8 )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue