make turning platforms be one-way only when player is inside of them already
This commit is contained in:
parent
2569986a87
commit
c024783ec8
2 changed files with 28 additions and 2 deletions
|
@ -2,6 +2,7 @@ extends Node2D
|
||||||
onready var anims = $AnimationPlayer
|
onready var anims = $AnimationPlayer
|
||||||
onready var flip_timer = $FlipTimer
|
onready var flip_timer = $FlipTimer
|
||||||
onready var delay_timer = $DelayTimer
|
onready var delay_timer = $DelayTimer
|
||||||
|
onready var collision_shape = $StaticBody2D/CollisionShape2D
|
||||||
export var time:float = 60
|
export var time:float = 60
|
||||||
export var delay = 0.0
|
export var delay = 0.0
|
||||||
export(int, "Wood", "Yellow") var color
|
export(int, "Wood", "Yellow") var color
|
||||||
|
@ -28,3 +29,14 @@ func _on_FlipTimer_timeout():
|
||||||
func _on_DelayTimer_timeout():
|
func _on_DelayTimer_timeout():
|
||||||
anims.play("idle")
|
anims.play("idle")
|
||||||
flip_timer.start(time_ms)
|
flip_timer.start(time_ms)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_DetectPlayer_area_entered(area):
|
||||||
|
if area.is_in_group("player"):
|
||||||
|
Debug.print("player in")
|
||||||
|
collision_shape.set_deferred("one_way_collision", true)
|
||||||
|
|
||||||
|
func _on_DetectPlayer_area_exited(area):
|
||||||
|
if area.is_in_group("player"):
|
||||||
|
Debug.print("player out")
|
||||||
|
collision_shape.set_deferred("one_way_collision", false)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=6 format=2]
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://objects/environment/turniwood/turning_platform.gd" type="Script" id=1]
|
[ext_resource path="res://objects/environment/turniwood/turning_platform.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://graphics/turniwood/turning_platform_yellow.png" type="Texture" id=2]
|
[ext_resource path="res://graphics/turniwood/turning_platform_yellow.png" type="Texture" id=2]
|
||||||
|
@ -6,6 +6,9 @@
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 4, 1 )
|
extents = Vector2( 4, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=4]
|
||||||
|
extents = Vector2( 3.5, 0.5 )
|
||||||
|
|
||||||
[sub_resource type="Animation" id=2]
|
[sub_resource type="Animation" id=2]
|
||||||
resource_name = "idle"
|
resource_name = "idle"
|
||||||
loop = true
|
loop = true
|
||||||
|
@ -115,7 +118,16 @@ collision_layer = 4
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
|
||||||
position = Vector2( 4, 4 )
|
position = Vector2( 4, 4 )
|
||||||
shape = SubResource( 1 )
|
shape = SubResource( 1 )
|
||||||
one_way_collision = true
|
one_way_collision_margin = 0.0
|
||||||
|
|
||||||
|
[node name="DetectPlayer" type="Area2D" parent="."]
|
||||||
|
collision_layer = 0
|
||||||
|
collision_mask = 2
|
||||||
|
monitorable = false
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="DetectPlayer"]
|
||||||
|
position = Vector2( 4, 4 )
|
||||||
|
shape = SubResource( 4 )
|
||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
anims/idle = SubResource( 2 )
|
anims/idle = SubResource( 2 )
|
||||||
|
@ -126,6 +138,8 @@ anims/turn = SubResource( 3 )
|
||||||
[node name="DelayTimer" type="Timer" parent="."]
|
[node name="DelayTimer" type="Timer" parent="."]
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
|
[connection signal="area_entered" from="DetectPlayer" to="." method="_on_DetectPlayer_area_entered"]
|
||||||
|
[connection signal="area_exited" from="DetectPlayer" to="." method="_on_DetectPlayer_area_exited"]
|
||||||
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"]
|
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"]
|
||||||
[connection signal="timeout" from="FlipTimer" to="." method="_on_FlipTimer_timeout"]
|
[connection signal="timeout" from="FlipTimer" to="." method="_on_FlipTimer_timeout"]
|
||||||
[connection signal="timeout" from="DelayTimer" to="." method="_on_DelayTimer_timeout"]
|
[connection signal="timeout" from="DelayTimer" to="." method="_on_DelayTimer_timeout"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue