Fixed Wallslide Detection
This commit is contained in:
parent
1fd9f6b690
commit
7ca590b90e
@ -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"
|
# Being able to touch a vertical surface over this length also makes it a qualified "wall"
|
||||||
# Also sets wall_touch_direction
|
# Also sets wall_touch_direction
|
||||||
func is_touching_wall_completely() -> bool:
|
func is_touching_wall_completely() -> bool:
|
||||||
|
var value = true
|
||||||
for left_raycast in left_wall_raycasts.get_children():
|
for left_raycast in left_wall_raycasts.get_children():
|
||||||
if left_raycast.is_colliding():
|
wall_touch_direction = -1
|
||||||
wall_touch_direction = -1
|
if !left_raycast.is_colliding():
|
||||||
return true
|
value = false
|
||||||
|
continue
|
||||||
|
if value == true: return value
|
||||||
|
|
||||||
|
value = true
|
||||||
for right_raycast in right_wall_raycasts.get_children():
|
for right_raycast in right_wall_raycasts.get_children():
|
||||||
if right_raycast.is_colliding():
|
wall_touch_direction = 1
|
||||||
wall_touch_direction = 1
|
if !right_raycast.is_colliding():
|
||||||
return true
|
value = false
|
||||||
return false
|
continue
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
# Attached to wall state is in the PlayerStateMachine
|
# Attached to wall state is in the PlayerStateMachine
|
||||||
|
|||||||
@ -15,6 +15,7 @@ onready var slope_raycast = get_node("%SlopeRaycast")
|
|||||||
|
|
||||||
var facing = 1
|
var facing = 1
|
||||||
var didTurn
|
var didTurn
|
||||||
|
var state_time := 0.0
|
||||||
|
|
||||||
# Adds the intial states
|
# Adds the intial states
|
||||||
func _ready():
|
func _ready():
|
||||||
@ -126,7 +127,7 @@ func get_horizontal_direction() -> Vector2:
|
|||||||
|
|
||||||
|
|
||||||
# Determines which state should be active at the moment
|
# Determines which state should be active at the moment
|
||||||
func _get_transition(_delta):
|
func _get_transition(delta):
|
||||||
parent.get_node("StateLabel").text = (
|
parent.get_node("StateLabel").text = (
|
||||||
self.state
|
self.state
|
||||||
# + " x vel:"
|
# + " x vel:"
|
||||||
@ -135,6 +136,7 @@ func _get_transition(_delta):
|
|||||||
# + String(round(parent.velocity.y / 10))
|
# + String(round(parent.velocity.y / 10))
|
||||||
)
|
)
|
||||||
var new_state
|
var new_state
|
||||||
|
state_time += delta
|
||||||
if !parent.is_on_floor():
|
if !parent.is_on_floor():
|
||||||
if parent.velocity.y < 0:
|
if parent.velocity.y < 0:
|
||||||
new_state = states.jump
|
new_state = states.jump
|
||||||
@ -175,6 +177,7 @@ func _get_transition(_delta):
|
|||||||
new_state = states.duck
|
new_state = states.duck
|
||||||
coyote_hanging = false
|
coyote_hanging = false
|
||||||
if new_state != self.state:
|
if new_state != self.state:
|
||||||
|
state_time = 0
|
||||||
return new_state
|
return new_state
|
||||||
init_boost = false
|
init_boost = false
|
||||||
return null
|
return null
|
||||||
@ -195,6 +198,7 @@ func _enter_state(new_state, old_state):
|
|||||||
match new_state:
|
match new_state:
|
||||||
states.walk:
|
states.walk:
|
||||||
# TODO I need this when there is a turn happening between two different states
|
# 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:
|
if old_state == states.idle && didTurn:
|
||||||
anim_state_playback.travel("idleTurn")
|
anim_state_playback.travel("idleTurn")
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -87,10 +87,10 @@ wait_time = 20.0
|
|||||||
[node name="BlobbyCam" parent="." instance=ExtResource( 12 )]
|
[node name="BlobbyCam" parent="." instance=ExtResource( 12 )]
|
||||||
|
|
||||||
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
|
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
|
||||||
frame = 6
|
frame = 0
|
||||||
|
|
||||||
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
|
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
|
||||||
frame = 11
|
frame = 5
|
||||||
|
|
||||||
[node name="Blobby" parent="." instance=ExtResource( 2 )]
|
[node name="Blobby" parent="." instance=ExtResource( 2 )]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
@ -109,7 +109,7 @@ position = Vector2( 72, -168 )
|
|||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
|
|
||||||
[node name="KinematicBody2D" type="KinematicBody2D" parent="FlyingPlatform"]
|
[node name="KinematicBody2D" type="KinematicBody2D" parent="FlyingPlatform"]
|
||||||
collision_layer = 8
|
collision_layer = 32
|
||||||
collision_mask = 0
|
collision_mask = 0
|
||||||
motion/sync_to_physics = true
|
motion/sync_to_physics = true
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ position = Vector2( 264, -234 )
|
|||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
|
|
||||||
[node name="KinematicBody2D" type="KinematicBody2D" parent="FlyingPlatform2"]
|
[node name="KinematicBody2D" type="KinematicBody2D" parent="FlyingPlatform2"]
|
||||||
collision_layer = 8
|
collision_layer = 16
|
||||||
collision_mask = 0
|
collision_mask = 0
|
||||||
motion/sync_to_physics = true
|
motion/sync_to_physics = true
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ position = Vector2( 552, -234 )
|
|||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
|
|
||||||
[node name="KinematicBody2D" type="KinematicBody2D" parent="FlyingPlatform3"]
|
[node name="KinematicBody2D" type="KinematicBody2D" parent="FlyingPlatform3"]
|
||||||
collision_layer = 8
|
collision_layer = 16
|
||||||
collision_mask = 0
|
collision_mask = 0
|
||||||
motion/sync_to_physics = true
|
motion/sync_to_physics = true
|
||||||
|
|
||||||
|
|||||||
@ -139,7 +139,7 @@ shape = SubResource( 3 )
|
|||||||
position = Vector2( 0, 1.5 )
|
position = Vector2( 0, 1.5 )
|
||||||
z_index = -1
|
z_index = -1
|
||||||
frames = SubResource( 5 )
|
frames = SubResource( 5 )
|
||||||
frame = 20
|
frame = 14
|
||||||
playing = true
|
playing = true
|
||||||
|
|
||||||
[node name="Portal" parent="." instance=ExtResource( 42 )]
|
[node name="Portal" parent="." instance=ExtResource( 42 )]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user