Make door automatically open when players bump into them

This commit is contained in:
Hamcha 2020-07-16 14:36:08 +02:00
parent 5316affe0e
commit 1ecbc87400
Signed by: hamcha
GPG key ID: 41467804B19A3315
2 changed files with 12 additions and 1 deletions

View file

@ -69,3 +69,6 @@ func serialize():
func deserialize(data):
pass
func _open_sensor_triggered():
rpc("set_open", $Sprite.animation == "close")

View file

@ -42,7 +42,7 @@ animations = [ {
} ]
[sub_resource type="CircleShape2D" id=8]
radius = 64.0
radius = 18.0
[node name="Door" type="StaticBody2D"]
input_pickable = true
@ -71,8 +71,16 @@ script = ExtResource( 3 )
position = Vector2( 16, 16 )
shape = SubResource( 8 )
[node name="CloseRange" type="Area2D" parent="."]
script = ExtResource( 3 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="CloseRange"]
position = Vector2( 16, 16 )
shape = SubResource( 8 )
[node name="PowerManager" type="Node" parent="."]
script = ExtResource( 4 )
power_usage = 2.0
[connection signal="animation_finished" from="Sprite" to="." method="_animation_finished"]
[connection signal="timeout" from="Timer" to="." method="_close_timer_triggered"]
[connection signal="player_entered" from="CloseRange" to="." method="_open_sensor_triggered"]