Fixed Wallslide Detection

This commit is contained in:
Jakob Feldmann 2023-03-13 19:03:29 +01:00
parent 1fd9f6b690
commit 7ca590b90e
4 changed files with 24 additions and 14 deletions

View File

@ -210,15 +210,21 @@ func is_reversing_horizontal_movement(direction: Vector2) -> bool:
# Being able to touch a vertical surface over this length also makes it a qualified "wall"
# Also sets wall_touch_direction
func is_touching_wall_completely() -> bool:
var value = true
for left_raycast in left_wall_raycasts.get_children():
if left_raycast.is_colliding():
wall_touch_direction = -1
return true
if !left_raycast.is_colliding():
value = false
continue
if value == true: return value
value = true
for right_raycast in right_wall_raycasts.get_children():
if right_raycast.is_colliding():
wall_touch_direction = 1
return true
return false
if !right_raycast.is_colliding():
value = false
continue
return value
# Attached to wall state is in the PlayerStateMachine

View File

@ -15,6 +15,7 @@ onready var slope_raycast = get_node("%SlopeRaycast")
var facing = 1
var didTurn
var state_time := 0.0
# Adds the intial states
func _ready():
@ -126,7 +127,7 @@ func get_horizontal_direction() -> Vector2:
# Determines which state should be active at the moment
func _get_transition(_delta):
func _get_transition(delta):
parent.get_node("StateLabel").text = (
self.state
# + " x vel:"
@ -135,6 +136,7 @@ func _get_transition(_delta):
# + String(round(parent.velocity.y / 10))
)
var new_state
state_time += delta
if !parent.is_on_floor():
if parent.velocity.y < 0:
new_state = states.jump
@ -175,6 +177,7 @@ func _get_transition(_delta):
new_state = states.duck
coyote_hanging = false
if new_state != self.state:
state_time = 0
return new_state
init_boost = false
return null
@ -195,6 +198,7 @@ func _enter_state(new_state, old_state):
match new_state:
states.walk:
# TODO I need this when there is a turn happening between two different states
# TODO Queue animation and only play if state time is exceeded, to not play animation on too small jumps/short wallslides
if old_state == states.idle && didTurn:
anim_state_playback.travel("idleTurn")
else:

View File

@ -87,10 +87,10 @@ wait_time = 20.0
[node name="BlobbyCam" parent="." instance=ExtResource( 12 )]
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
frame = 6
frame = 0
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
frame = 11
frame = 5
[node name="Blobby" parent="." instance=ExtResource( 2 )]
unique_name_in_owner = true
@ -109,7 +109,7 @@ position = Vector2( 72, -168 )
script = ExtResource( 5 )
[node name="KinematicBody2D" type="KinematicBody2D" parent="FlyingPlatform"]
collision_layer = 8
collision_layer = 32
collision_mask = 0
motion/sync_to_physics = true
@ -129,7 +129,7 @@ position = Vector2( 264, -234 )
script = ExtResource( 5 )
[node name="KinematicBody2D" type="KinematicBody2D" parent="FlyingPlatform2"]
collision_layer = 8
collision_layer = 16
collision_mask = 0
motion/sync_to_physics = true
@ -149,7 +149,7 @@ position = Vector2( 552, -234 )
script = ExtResource( 5 )
[node name="KinematicBody2D" type="KinematicBody2D" parent="FlyingPlatform3"]
collision_layer = 8
collision_layer = 16
collision_mask = 0
motion/sync_to_physics = true

View File

@ -139,7 +139,7 @@ shape = SubResource( 3 )
position = Vector2( 0, 1.5 )
z_index = -1
frames = SubResource( 5 )
frame = 20
frame = 14
playing = true
[node name="Portal" parent="." instance=ExtResource( 42 )]