chomp vault to help getting up corners
This commit is contained in:
parent
4b4138a542
commit
5cf87d8bb7
5 changed files with 118 additions and 10 deletions
|
@ -13,12 +13,19 @@ extends CharacterBody2D
|
|||
@export var jump_power: float
|
||||
@export var splat_launch_power: float
|
||||
@export var splat_offset: float
|
||||
@export var chomp_vault_impulse: Vector2
|
||||
|
||||
@export_group("Internal References")
|
||||
@export var state_chart: StateChart
|
||||
@export var graphics: Node2D
|
||||
@export var run_animation: SpritesheetAnimation
|
||||
|
||||
@export var wall_cast: ShapeCast2D
|
||||
@export var corner_cast: RayCast2D
|
||||
@export var corner_height_cast: RayCast2D
|
||||
@export var corner_snap_point: Node2D
|
||||
@export var vault_off_point: Node2D
|
||||
|
||||
|
||||
@onready var start_position: Vector2 = global_position
|
||||
|
||||
|
@ -93,6 +100,30 @@ func _start_jump() -> void:
|
|||
#endregion
|
||||
|
||||
|
||||
#region ChompVault
|
||||
func _check_for_corner(_delta: float) -> void:
|
||||
if signf(input_dir.x) == signf(graphics.scale.x):
|
||||
corner_cast.force_raycast_update()
|
||||
if not corner_cast.is_colliding():
|
||||
wall_cast.force_shapecast_update()
|
||||
if wall_cast.is_colliding():
|
||||
state_chart.send_event(&"corner_detected")
|
||||
|
||||
func _start_chomp_vault() -> void:
|
||||
corner_height_cast.force_raycast_update()
|
||||
global_position.x = wall_cast.get_collision_point(0).x
|
||||
global_position.y = corner_height_cast.get_collision_point().y
|
||||
global_position -= to_local(corner_snap_point.global_position)
|
||||
velocity = Vector2.ZERO
|
||||
|
||||
func _end_chomp_vault() -> void:
|
||||
global_position += to_local(corner_snap_point.global_position)
|
||||
global_position -= to_local(vault_off_point.global_position)
|
||||
velocity = chomp_vault_impulse
|
||||
velocity.x *= signf(graphics.scale.x)
|
||||
#endregion
|
||||
|
||||
|
||||
#region Missile
|
||||
func _restore_graphics_rotation() -> void:
|
||||
graphics.rotation = 0.0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=35 format=3 uid="uid://bwtpsjpe2lf7l"]
|
||||
[gd_scene load_steps=36 format=3 uid="uid://bwtpsjpe2lf7l"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dhyi4yn0xleoy" path="res://objects/player/player.gd" id="1_xs4s5"]
|
||||
[ext_resource type="Texture2D" uid="uid://c71nqfyw4a3v4" path="res://assets/textures/player/capri.png" id="3_trcll"]
|
||||
|
@ -23,6 +23,9 @@
|
|||
[sub_resource type="CircleShape2D" id="CircleShape2D_tvyy1"]
|
||||
radius = 6.0
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_l55sg"]
|
||||
size = Vector2(4, 5)
|
||||
|
||||
[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_45rsp"]
|
||||
streams_count = 3
|
||||
stream_0/stream = ExtResource("9_8c74o")
|
||||
|
@ -105,7 +108,7 @@ script = ExtResource("8_8i2im")
|
|||
expression = "velocity.y > 0.0"
|
||||
metadata/_custom_type_script = "uid://b6u7unac5srh0"
|
||||
|
||||
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("state_chart", "graphics", "run_animation")]
|
||||
[node name="Player" type="CharacterBody2D" node_paths=PackedStringArray("state_chart", "graphics", "run_animation", "wall_cast", "corner_cast", "corner_height_cast", "corner_snap_point", "vault_off_point")]
|
||||
collision_layer = 16
|
||||
collision_mask = 3
|
||||
floor_snap_length = 3.0
|
||||
|
@ -118,9 +121,15 @@ gravity = 450.0
|
|||
jump_power = 180.0
|
||||
splat_launch_power = 240.0
|
||||
splat_offset = 6.0
|
||||
chomp_vault_impulse = Vector2(60, -60)
|
||||
state_chart = NodePath("StateChart")
|
||||
graphics = NodePath("Graphics")
|
||||
run_animation = NodePath("Graphics/Sprite/Run")
|
||||
wall_cast = NodePath("Graphics/CornerDetector/WallCast")
|
||||
corner_cast = NodePath("Graphics/CornerDetector/CornerCast")
|
||||
corner_height_cast = NodePath("Graphics/CornerDetector/CornerHeightCast")
|
||||
corner_snap_point = NodePath("Graphics/CornerDetector/CornerSnapPoint")
|
||||
vault_off_point = NodePath("Graphics/CornerDetector/VaultOffPoint")
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_tvyy1")
|
||||
|
@ -131,9 +140,9 @@ debug_color = Color(3.32102e-06, 0.648976, 0.161954, 0.42)
|
|||
[node name="Sprite" type="Sprite2D" parent="Graphics"]
|
||||
texture = ExtResource("3_trcll")
|
||||
offset = Vector2(0, -2)
|
||||
hframes = 4
|
||||
hframes = 8
|
||||
vframes = 4
|
||||
frame = 10
|
||||
frame = 7
|
||||
region_rect = Rect2(0, 0, 64, 64)
|
||||
|
||||
[node name="Idle" type="Node" parent="Graphics/Sprite"]
|
||||
|
@ -178,6 +187,40 @@ first_frame = Vector2i(2, 3)
|
|||
frames = 2
|
||||
fps = 8.0
|
||||
|
||||
[node name="ChompVault" type="Node" parent="Graphics/Sprite"]
|
||||
editor_description = "Triggers transition out of ChompVault state when animation is finished."
|
||||
script = ExtResource("4_bsdw5")
|
||||
first_frame = Vector2i(4, 0)
|
||||
frames = 3
|
||||
fps = 10.0
|
||||
metadata/_custom_type_script = "uid://cv55s54clajw5"
|
||||
|
||||
[node name="CornerDetector" type="Node2D" parent="Graphics"]
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="WallCast" type="ShapeCast2D" parent="Graphics/CornerDetector"]
|
||||
position = Vector2(0, 2.5)
|
||||
enabled = false
|
||||
shape = SubResource("RectangleShape2D_l55sg")
|
||||
target_position = Vector2(6, 0)
|
||||
max_results = 1
|
||||
|
||||
[node name="CornerCast" type="RayCast2D" parent="Graphics/CornerDetector"]
|
||||
position = Vector2(0, -1)
|
||||
enabled = false
|
||||
target_position = Vector2(8, 0)
|
||||
|
||||
[node name="CornerHeightCast" type="RayCast2D" parent="Graphics/CornerDetector"]
|
||||
position = Vector2(9, -1)
|
||||
enabled = false
|
||||
target_position = Vector2(0, 8)
|
||||
|
||||
[node name="CornerSnapPoint" type="Node2D" parent="Graphics/CornerDetector"]
|
||||
position = Vector2(4, 2)
|
||||
|
||||
[node name="VaultOffPoint" type="Node2D" parent="Graphics/CornerDetector"]
|
||||
position = Vector2(2, 7)
|
||||
|
||||
[node name="Sounds" type="Node" parent="."]
|
||||
|
||||
[node name="Jump" type="AudioStreamPlayer" parent="Sounds"]
|
||||
|
@ -330,9 +373,16 @@ delay_in_seconds = "0.0"
|
|||
editor_description = "Player is falling down."
|
||||
script = ExtResource("10_mvu25")
|
||||
|
||||
[node name="on CornerDetected" type="Node" parent="StateChart/Root/Airborne/Falling"]
|
||||
script = ExtResource("7_rgjdc")
|
||||
to = NodePath("../../../Floating/ChompVault")
|
||||
event = &"corner_detected"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="Jumping" type="Node" parent="StateChart/Root/Airborne"]
|
||||
editor_description = "Player has jumped and is rising."
|
||||
script = ExtResource("10_mvu25")
|
||||
script = ExtResource("6_jnxnd")
|
||||
initial_state = NodePath("FromGround")
|
||||
|
||||
[node name="if DownVelocity" type="Node" parent="StateChart/Root/Airborne/Jumping"]
|
||||
editor_description = "Transition to the falling state if moving downwards."
|
||||
|
@ -341,6 +391,18 @@ to = NodePath("../../Falling")
|
|||
guard = SubResource("Resource_whx0j")
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="on CornerDetected" type="Node" parent="StateChart/Root/Airborne/Jumping"]
|
||||
script = ExtResource("7_rgjdc")
|
||||
to = NodePath("../../../Floating/ChompVault")
|
||||
event = &"corner_detected"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="FromGround" type="Node" parent="StateChart/Root/Airborne/Jumping"]
|
||||
script = ExtResource("10_mvu25")
|
||||
|
||||
[node name="NoBoost" type="Node" parent="StateChart/Root/Airborne/Jumping"]
|
||||
script = ExtResource("10_mvu25")
|
||||
|
||||
[node name="Missile" type="Node" parent="StateChart/Root/Airborne"]
|
||||
editor_description = "Player is hurtling through the air and ricocheting off of surfaces."
|
||||
script = ExtResource("10_mvu25")
|
||||
|
@ -356,6 +418,16 @@ delay_in_seconds = "0.0"
|
|||
script = ExtResource("6_jnxnd")
|
||||
initial_state = NodePath("UnSplat")
|
||||
|
||||
[node name="ChompVault" type="Node" parent="StateChart/Root/Floating"]
|
||||
editor_description = "Player is launching off of a corner."
|
||||
script = ExtResource("10_mvu25")
|
||||
|
||||
[node name="on AnimationFinished" type="Node" parent="StateChart/Root/Floating/ChompVault"]
|
||||
script = ExtResource("7_rgjdc")
|
||||
to = NodePath("../../../Airborne/Jumping/NoBoost")
|
||||
event = &"*animation_finished"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="Splat" type="Node" parent="StateChart/Root/Floating"]
|
||||
editor_description = "Player has slammed into a surface (and has a moment to perform an action?)"
|
||||
script = ExtResource("10_mvu25")
|
||||
|
@ -380,6 +452,7 @@ script = ExtResource("7_rgjdc")
|
|||
to = NodePath("../../../Airborne/Falling")
|
||||
delay_in_seconds = "0.25"
|
||||
|
||||
[connection signal="finished" from="Graphics/Sprite/ChompVault" to="StateChart/Root/Floating/ChompVault/on AnimationFinished" method="take"]
|
||||
[connection signal="taken" from="StateChart/Root/on Killed" to="." method="_reset_position"]
|
||||
[connection signal="taken" from="StateChart/Root/on Killed" to="Sounds/Death" method="play"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Grounded/Standing/Idle" to="Graphics/Sprite/Idle" method="play"]
|
||||
|
@ -387,15 +460,16 @@ delay_in_seconds = "0.25"
|
|||
[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Standing/Stopping" to="." method="_slow_to_stop"]
|
||||
[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Standing/Stopping" to="." method="_scale_run_animation"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Grounded/Running" to="Graphics/Sprite/Run" method="play"]
|
||||
[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Running" to="." method="_apply_run_acceleration"]
|
||||
[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Running" to="." method="_scale_run_animation"]
|
||||
[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Running" to="." method="_apply_run_acceleration"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Grounded/Turning" to="Graphics/Sprite/Skid" method="play"]
|
||||
[connection signal="state_physics_processing" from="StateChart/Root/Grounded/Turning" to="." method="_apply_turn_acceleration"]
|
||||
[connection signal="state_physics_processing" from="StateChart/Root/Airborne" to="." method="_apply_gravity"]
|
||||
[connection signal="state_physics_processing" from="StateChart/Root/Airborne" to="." method="_check_for_corner"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Airborne/Falling" to="Graphics/Sprite/Fall" method="play"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Airborne/Jumping" to="." method="_start_jump"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Airborne/Jumping" to="Graphics/Sprite/Jump" method="play"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Airborne/Jumping" to="Sounds/Jump" method="play"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Airborne/Jumping/FromGround" to="." method="_start_jump"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Airborne/Jumping/FromGround" to="Sounds/Jump" method="play"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Airborne/Missile" to="Graphics/Sprite/Missile" method="play"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Airborne/Missile" to="Sounds/Whee" method="play"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Airborne/Missile" to="Sounds/Wallkick" method="play"]
|
||||
|
@ -403,6 +477,9 @@ delay_in_seconds = "0.25"
|
|||
[connection signal="state_physics_processing" from="StateChart/Root/Airborne/Missile" to="." method="_check_for_splat"]
|
||||
[connection signal="state_physics_processing" from="StateChart/Root/Airborne/Missile" to="." method="_face_towards_velocity"]
|
||||
[connection signal="taken" from="StateChart/Root/Airborne/Missile/on Splatted" to="Sounds/HitWall" method="play"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Floating/ChompVault" to="." method="_start_chomp_vault"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Floating/ChompVault" to="Graphics/Sprite/ChompVault" method="play"]
|
||||
[connection signal="taken" from="StateChart/Root/Floating/ChompVault/on AnimationFinished" to="." method="_end_chomp_vault"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Floating/Splat" to="Graphics/Sprite/Splat" method="play"]
|
||||
[connection signal="taken" from="StateChart/Root/Floating/Splat/on JumpPressed" to="." method="_do_splat_launch"]
|
||||
[connection signal="state_entered" from="StateChart/Root/Floating/UnSplat" to="Graphics/Sprite/UnSplat" method="play"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue