diff --git a/src/actors/players/playerE/PlayerE-Movement_StateReceiver.gd b/src/actors/players/playerE/PlayerE-Movement_StateReceiver.gd index cec19d8..058064b 100644 --- a/src/actors/players/playerE/PlayerE-Movement_StateReceiver.gd +++ b/src/actors/players/playerE/PlayerE-Movement_StateReceiver.gd @@ -9,6 +9,8 @@ var player_number: int = 1 onready var pew_machine = $"%PewMachine" onready var stamina_component = $"%Stamina_Component" +onready var ladder_detector = $"%LadderDetector" + var state_stamina_cost :Dictionary @@ -58,8 +60,10 @@ var _wants_crouch :bool func wants_crouch() -> bool: if Input.is_action_pressed("crouch_" + str(player_number)): _wants_crouch = true + ladder_detector.position.y = 2 return true else: + ladder_detector.position.y = 0 _wants_crouch = false return false @@ -332,6 +336,9 @@ func _state_process_physics_fall(): flip_sprite_to_movement_direction() var foo = $"%LedgeDetector".is_colliding() var bar = $"%WallDetector".is_colliding() + + #parent.get_node("CollisionShape2D").set_deferred("disabled", false) + parent.set_collision_mask_bit(9,true) if $"%LedgeDetector".is_colliding() and !$"%WallDetector".is_colliding(): #print("it touched me!") @@ -442,8 +449,6 @@ func get_climb_shape_location() -> Vector2: func _state_process_physics_climb(): - #$"../LadderDetector".set_enabled(false) - var ladder_location = get_climb_shape_location() if ladder_location != Vector2(-1,-1): #UiManager.debug_text = str(ladder_location) + '\n' + str(ladder_location - parent.global_position) #+ '\n' + str(parent.global_position.distance_to(ladder_location)) @@ -462,8 +467,8 @@ func _state_process_physics_climb(): else: return request_state_change.call_func('idle') - - if _wants_crouch: + + if _wants_jump: request_state_change.call_func('fall') return @@ -525,6 +530,12 @@ func _state_process_physics_crouch(): request_state_change.call_func('idle') return + if _wants_jump == true: + ##TODO: Done to drop through one-way floors + #parent.get_node("CollisionShape2D").set_deferred("disabled", true) + parent.set_collision_mask_bit(9,false) + return + if !parent.is_on_floor(): request_state_change.call_func('fall') return @@ -536,6 +547,10 @@ func _state_process_physics_crouch(): request_state_change.call_func('move') return + if $"%LadderDetector".is_colliding(): + request_state_change.call_func('climb') + return + apply_movement_to_parent( velocity_controller.calculate_velocity( physics_delta , diff --git a/src/actors/players/playerE/states/climb.tres b/src/actors/players/playerE/states/climb.tres index c8b7edd..559c73f 100644 --- a/src/actors/players/playerE/states/climb.tres +++ b/src/actors/players/playerE/states/climb.tres @@ -14,7 +14,7 @@ min_acceleration = Vector2( 0, 0 ) acceleration = Vector2( 0, 280 ) max_acceleration = Vector2( 0, 0 ) jerk_factor = Vector2( 1, 1 ) -horizontal_speed = 20.0 +horizontal_speed = 50.0 horizontal_acceleration = 0.0 horizontal_speed_offset = 0.0 horizontal_speed_offset_acceleration = 0.0 diff --git a/src/levels/TC_05.tscn b/src/levels/TC_05.tscn index f8576a5..d08b0bc 100644 --- a/src/levels/TC_05.tscn +++ b/src/levels/TC_05.tscn @@ -9,7 +9,7 @@ [sub_resource type="RectangleShape2D" id=2] [sub_resource type="RectangleShape2D" id=3] -extents = Vector2( 8, 48 ) +extents = Vector2( 8, 40 ) [node name="TC_05" groups=["world"] instance=ExtResource( 1 )] @@ -92,9 +92,9 @@ collision_layer = 1024 collision_mask = 0 [node name="CollisionShape2D" type="CollisionShape2D" parent="Ladders" index="0"] -position = Vector2( 136, 96 ) +position = Vector2( 136, 88 ) shape = SubResource( 3 ) [node name="CollisionShape2D2" type="CollisionShape2D" parent="Ladders" index="1"] -position = Vector2( 200, 96 ) +position = Vector2( 200, 88 ) shape = SubResource( 3 )