fix (i think....) the silly one-way platform issueeee

This commit is contained in:
Haze Weathers 2023-03-08 19:26:09 -05:00
parent 57b341f515
commit 7606485692
5 changed files with 15 additions and 14 deletions

View file

@ -3,8 +3,9 @@
[ext_resource path="res://graphics/moving_platform/moving_platform.png" type="Texture" id=1] [ext_resource path="res://graphics/moving_platform/moving_platform.png" type="Texture" id=1]
[ext_resource path="res://objects/environment/moving_platform/moving_platform.gd" type="Script" id=2] [ext_resource path="res://objects/environment/moving_platform/moving_platform.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="SegmentShape2D" id=1]
extents = Vector2( 4, 2 ) a = Vector2( -4, -2 )
b = Vector2( 4, -2 )
[node name="MovingPlatform" type="KinematicBody2D"] [node name="MovingPlatform" type="KinematicBody2D"]
collision_layer = 4 collision_layer = 4

View file

@ -2,11 +2,12 @@ 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 onready var body = $StaticBody2D
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
onready var time_ms = time * 0.0166666666666667 # Time is converted from frames @ 60fps to ms onready var time_ms = time / 60.0 # Time is converted from frames @ 60fps to ms
onready var collision_layer = body.collision_layer
func _ready(): func _ready():
#Auto start if delay variable is zero #Auto start if delay variable is zero
@ -33,10 +34,8 @@ func _on_DelayTimer_timeout():
func _on_DetectPlayer_area_entered(area): func _on_DetectPlayer_area_entered(area):
if area.is_in_group("player"): if area.is_in_group("player"):
Debug.print("player in") body.collision_layer = 0
collision_shape.set_deferred("one_way_collision", true)
func _on_DetectPlayer_area_exited(area): func _on_DetectPlayer_area_exited(area):
if area.is_in_group("player"): if area.is_in_group("player"):
Debug.print("player out") body.collision_layer = collision_layer
collision_shape.set_deferred("one_way_collision", false)

View file

@ -43,6 +43,7 @@ var arrowpos = Vector2(5,3)
#Set initial respawn point #Set initial respawn point
func _ready(): func _ready():
$LeftShoe.shape.length = 0.0
Game.respawn_point = global_position Game.respawn_point = global_position
func _physics_process(delta): func _physics_process(delta):

View file

@ -36,7 +36,7 @@ extents = Vector2( 2.5, 5 )
extents = Vector2( 2.5, 5 ) extents = Vector2( 2.5, 5 )
[sub_resource type="RayShape2D" id=44] [sub_resource type="RayShape2D" id=44]
length = 1.0 length = 0.01
[sub_resource type="Animation" id=29] [sub_resource type="Animation" id=29]
resource_name = "climb" resource_name = "climb"
@ -645,12 +645,12 @@ shape = SubResource( 6 )
position = Vector2( 0.5, 5 ) position = Vector2( 0.5, 5 )
shape = SubResource( 39 ) shape = SubResource( 39 )
[node name="CollisionShape2D2" type="CollisionShape2D" parent="." groups=["sword"]] [node name="LeftShoe" type="CollisionShape2D" parent="." groups=["sword"]]
position = Vector2( 3, 9 ) position = Vector2( -2, 10 )
shape = SubResource( 44 ) shape = SubResource( 44 )
[node name="CollisionShape2D3" type="CollisionShape2D" parent="." groups=["sword"]] [node name="RightShoe" type="CollisionShape2D" parent="." groups=["sword"]]
position = Vector2( -2, 9 ) position = Vector2( 3, 10 )
shape = SubResource( 44 ) shape = SubResource( 44 )
[node name="ClimbRay" type="RayCast2D" parent="."] [node name="ClimbRay" type="RayCast2D" parent="."]

View file

@ -45,7 +45,7 @@ points = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 )
points = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 ) points = PoolVector2Array( 8, 8, 0, 8, 0, 0, 8, 0 )
[sub_resource type="ConvexPolygonShape2D" id=17] [sub_resource type="ConvexPolygonShape2D" id=17]
points = PoolVector2Array( 8, 6, 0, 6, 0, 2, 8, 2 ) points = PoolVector2Array( 8, 2, 0, 2, 0, 2, 8, 2 )
[resource] [resource]
0/name = "grass.png 0" 0/name = "grass.png 0"