basic slide and air glide mechanic
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
[ext_resource type="Resource" uid="uid://55b0dsvioj08" path="res://systems/inputs/base_mode/jump_pressed.tres" id="13_nob5r"]
|
||||
[ext_resource type="Shape3D" uid="uid://keseacdcooot" path="res://player_controller/resources/PlayerShape.tres" id="13_r7i3q"]
|
||||
[ext_resource type="Script" uid="uid://b5nk6ntlps3x0" path="res://systems/inputs/input_system.gd" id="16_v31n3"]
|
||||
[ext_resource type="Resource" uid="uid://b334rau1yxmm7" path="res://systems/inputs/base_mode/slide.tres" id="17_6lejt"]
|
||||
[ext_resource type="Resource" uid="uid://b334rau1yxmm7" path="res://systems/inputs/base_mode/slide_released.tres" id="17_6lejt"]
|
||||
[ext_resource type="Resource" uid="uid://htqvokm8mufq" path="res://systems/inputs/base_mode/move.tres" id="17_h6vvl"]
|
||||
[ext_resource type="PackedScene" uid="uid://cqduhd4opgwvm" path="res://systems/dash/dash_system.tscn" id="18_q5h8a"]
|
||||
[ext_resource type="Resource" uid="uid://bbce5wfwxpns1" path="res://systems/inputs/base_mode/slide_pressed.tres" id="18_q14ux"]
|
||||
@@ -87,6 +87,10 @@ MaxNumberOfEmpoweredActions = 3
|
||||
SimpleDashStrength = 15.0
|
||||
AimedDashTime = 0.2
|
||||
PostDashSpeed = 30.0
|
||||
AccelerationGroundSlide = 0.2
|
||||
AirGlideVSpeed = 3.0
|
||||
AccelerationAirGlide = 0.2
|
||||
DecelerationAirGlide = 0.0
|
||||
WallHugGravityLesseningFactor = 15.0
|
||||
WallHugDownwardMaxSpeed = 8.0
|
||||
WallHugHorizontalDeceleration = 0.5
|
||||
@@ -112,8 +116,8 @@ aim_pressed = ExtResource("9_nob5r")
|
||||
aim_released = ExtResource("8_lhb11")
|
||||
jump = ExtResource("10_4u7i3")
|
||||
jump_pressed = ExtResource("13_nob5r")
|
||||
slide = ExtResource("17_6lejt")
|
||||
slide_pressed = ExtResource("18_q14ux")
|
||||
slide_released = ExtResource("17_6lejt")
|
||||
hit = ExtResource("11_cresl")
|
||||
parry = ExtResource("18_ruloh")
|
||||
dash = ExtResource("12_34snm")
|
||||
@@ -501,6 +505,12 @@ to = NodePath("../../Airborne/CoyoteEnabled")
|
||||
event = &"start_falling"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Grounded"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Sliding/GroundSlide")
|
||||
event = &"slide"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="Mantling" type="Node" parent="StateChart/Root/Movement"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
@@ -520,6 +530,12 @@ delay_in_seconds = "0.0"
|
||||
script = ExtResource("26_infe6")
|
||||
initial_state = NodePath("SimpleJump")
|
||||
|
||||
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Jump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Sliding/AirGlide")
|
||||
event = &"slide"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnMantle" type="Node" parent="StateChart/Root/Movement/Jump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Mantling")
|
||||
@@ -576,6 +592,12 @@ script = ExtResource("27_34snm")
|
||||
script = ExtResource("26_infe6")
|
||||
initial_state = NodePath("GroundSlide")
|
||||
|
||||
[node name="OnMantle" type="Node" parent="StateChart/Root/Movement/Sliding"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Mantling")
|
||||
event = &"mantle"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="GroundSlide" type="Node" parent="StateChart/Root/Movement/Sliding"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
@@ -632,6 +654,12 @@ to = NodePath("../../Grounded")
|
||||
event = &"grounded"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnSlide" type="Node" parent="StateChart/Root/Movement/Airborne"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Sliding/AirGlide")
|
||||
event = &"slide"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="CoyoteEnabled" type="Node" parent="StateChart/Root/Movement/Airborne"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
@@ -748,6 +776,5 @@ delay_in_seconds = "0.0"
|
||||
[connection signal="input_rotate_y" from="InputController" to="." method="OnInputRotateY"]
|
||||
[connection signal="input_slam" from="InputController" to="." method="OnInputSlamPressed"]
|
||||
[connection signal="input_slide_ended" from="InputController" to="." method="OnInputSlideEnded"]
|
||||
[connection signal="input_slide_ongoing" from="InputController" to="." method="OnInputSlideOngoing"]
|
||||
[connection signal="input_slide_started" from="InputController" to="." method="OnInputSlideStarted"]
|
||||
[connection signal="WallDetected" from="WallHugSystem" to="." method="OnWallDetected"]
|
||||
|
||||
@@ -129,6 +129,22 @@ public partial class PlayerController : CharacterBody3D
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float TimeScaleAimInAir { get; set; } = 0.05f;
|
||||
|
||||
// Sliding and gliding
|
||||
[ExportGroup("Slide")]
|
||||
[ExportSubgroup("Ground slide")]
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float AccelerationGroundSlide = 1.0f;
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float DecelerationGroundSlide = 0.1f;
|
||||
|
||||
[ExportSubgroup("Air glide")]
|
||||
[Export(PropertyHint.Range, "0,10,0.01,or_greater")]
|
||||
public float AirGlideVSpeed { get; set; } = 1.0f;
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float AccelerationAirGlide = 1.0f;
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float DecelerationAirGlide = 0.1f;
|
||||
|
||||
// Wall hug
|
||||
[ExportGroup("Wall hug")]
|
||||
[Export(PropertyHint.Range, "0,50,0.1,or_greater")]
|
||||
@@ -235,6 +251,9 @@ public partial class PlayerController : CharacterBody3D
|
||||
private StateChartState _mantling;
|
||||
private StateChartState _simpleDash;
|
||||
private StateChartState _aimedDash;
|
||||
private StateChartState _sliding;
|
||||
private StateChartState _groundSliding;
|
||||
private StateChartState _airGliding;
|
||||
private StateChartState _onWall;
|
||||
private StateChartState _onWallHugging;
|
||||
private StateChartState _onWallHanging;
|
||||
@@ -293,12 +312,17 @@ public partial class PlayerController : CharacterBody3D
|
||||
_playerHeight = playerShape!.Height;
|
||||
_playerRadius = playerShape.Radius;
|
||||
|
||||
// State managementb
|
||||
// State management
|
||||
_playerState = StateChart.Of(GetNode("StateChart"));
|
||||
|
||||
_aiming = StateChartState.Of(GetNode("StateChart/Root/Aim/On"));
|
||||
_simpleDash = StateChartState.Of(GetNode("StateChart/Root/Movement/Dashing/Dash"));
|
||||
_aimedDash = StateChartState.Of(GetNode("StateChart/Root/Movement/Dashing/AimedDash"));
|
||||
|
||||
_sliding = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding"));
|
||||
_groundSliding = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding/GroundSlide"));
|
||||
_airGliding = StateChartState.Of(GetNode("StateChart/Root/Movement/Sliding/AirGlide"));
|
||||
|
||||
// _actionHanging = StateChartState.Of(GetNode("StateChart/Root/Actions/Hanging"));
|
||||
_powerExpired = StateChartState.Of(GetNode("StateChart/Root/PowerReserve/Expired"));
|
||||
_powerRecharging = StateChartState.Of(GetNode("StateChart/Root/PowerReserve/AtLeastOneCharge"));
|
||||
@@ -385,6 +409,11 @@ public partial class PlayerController : CharacterBody3D
|
||||
_aimedDash.StateEntered += OnAimedDashStarted;
|
||||
_aimedDash.StateExited += OnAimedDashFinished;
|
||||
|
||||
_sliding.StateEntered += SlideStarted;
|
||||
_sliding.StateExited += SlideEnded;
|
||||
_groundSliding.StatePhysicsProcessing += HandleGroundSlide;
|
||||
_airGliding.StatePhysicsProcessing += HandleAirGlide;
|
||||
|
||||
_simpleDashCooldownTimer.Timeout += DashCooldownTimeout;
|
||||
_airborneDashCooldownTimer.Timeout += AirborneDashCooldownTimeout;
|
||||
|
||||
@@ -481,6 +510,11 @@ public partial class PlayerController : CharacterBody3D
|
||||
_bufferedAction = BufferedActions.None;
|
||||
}
|
||||
|
||||
public bool IsGroundLike()
|
||||
{
|
||||
return GroundDetector.GetCollisionResult().Count > 0;
|
||||
}
|
||||
|
||||
public void HandleGrounded(float delta)
|
||||
{
|
||||
MoveOnGround(delta);
|
||||
@@ -572,8 +606,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
///////////////////////////
|
||||
public void HandleAirborne(float delta)
|
||||
{
|
||||
var isGroundLike = GroundDetector.GetCollisionResult().Count > 0;
|
||||
MoveInAir(delta, isGroundLike);
|
||||
MoveInAir(delta, IsGroundLike());
|
||||
if (isOnFloorCustom())
|
||||
_playerState.SendEvent("grounded");
|
||||
|
||||
@@ -610,10 +643,15 @@ public partial class PlayerController : CharacterBody3D
|
||||
_playerState.SendEvent("wall_hug");
|
||||
}
|
||||
}
|
||||
|
||||
public float ComputeVerticalSpeedGravity(float delta)
|
||||
{
|
||||
return Velocity.Y - CalculateGravityForce() * delta;
|
||||
}
|
||||
public void MoveInAir(double delta, bool isGroundLike = false)
|
||||
{
|
||||
var horizontalVelocity = isGroundLike ? ComputeHVelocityGround((float) delta) : ComputeHVelocityAir((float) delta);
|
||||
var verticalVelocity = Velocity.Y - (CalculateGravityForce() * (float)delta);
|
||||
var verticalVelocity = ComputeVerticalSpeedGravity((float) delta);
|
||||
Velocity = new Vector3(horizontalVelocity.X, verticalVelocity, horizontalVelocity.Z);
|
||||
}
|
||||
|
||||
@@ -1102,18 +1140,65 @@ public partial class PlayerController : CharacterBody3D
|
||||
_playerState.SendEvent("grounded");
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
// Slide management //
|
||||
///////////////////////////
|
||||
public void OnInputSlideStarted()
|
||||
{
|
||||
}
|
||||
public void OnInputSlideOngoing()
|
||||
{
|
||||
_playerState.SendEvent("slide");
|
||||
}
|
||||
public void OnInputSlideEnded()
|
||||
{
|
||||
_playerState.SendEvent("slide_released");
|
||||
}
|
||||
|
||||
public void SlideStarted()
|
||||
{
|
||||
_targetSpeed = Velocity.Length();
|
||||
}
|
||||
public void SlideOnGround(float delta)
|
||||
{
|
||||
var horizontalVelocity = ComputeHVelocity(delta, AccelerationGroundSlide, DecelerationGroundSlide);
|
||||
Velocity = new Vector3(horizontalVelocity.X, Velocity.Y, horizontalVelocity.Z);
|
||||
}
|
||||
public void HandleGroundSlide(float delta)
|
||||
{
|
||||
SlideOnGround(delta);
|
||||
if (MantleSystem.IsMantlePossible && IsPlayerInputtingForward()) _playerState.SendEvent("mantle");
|
||||
|
||||
if (!isOnFloorCustom())
|
||||
_playerState.SendEvent("start_falling");
|
||||
}
|
||||
public void GlideInAir(float delta)
|
||||
{
|
||||
var horizontalVelocity = ComputeHVelocity(delta, AccelerationAirGlide, DecelerationAirGlide);
|
||||
|
||||
float verticalSpeed;
|
||||
if (Velocity.Y < -AirGlideVSpeed) verticalSpeed = -AirGlideVSpeed;
|
||||
else if (Velocity.Y > 0) verticalSpeed = ComputeVerticalSpeedGravity(delta);
|
||||
else verticalSpeed = Mathf.Lerp(Velocity.Y, -AirGlideVSpeed, delta);
|
||||
|
||||
Velocity = new Vector3(horizontalVelocity.X, verticalSpeed, horizontalVelocity.Z);
|
||||
}
|
||||
public void HandleAirGlide(float delta)
|
||||
{
|
||||
GlideInAir(delta);
|
||||
if (MantleSystem.IsMantlePossible && IsPlayerInputtingForward()) _playerState.SendEvent("mantle");
|
||||
|
||||
if (isOnFloorCustom())
|
||||
_playerState.SendEvent("grounded");
|
||||
}
|
||||
public void SlideEnded()
|
||||
{
|
||||
_targetSpeed = WalkSpeed;
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
// Slam Management ///////
|
||||
///////////////////////////
|
||||
public void OnInputSlamPressed()
|
||||
{
|
||||
GD.Print("Slam pressed");
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
@@ -1221,14 +1306,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
// Slam Management ///////
|
||||
///////////////////////////
|
||||
public void OnInputSlamPressed()
|
||||
{
|
||||
GD.Print("Slam pressed");
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
// Parry Management ///////
|
||||
///////////////////////////
|
||||
@@ -1279,7 +1356,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
}
|
||||
|
||||
// Weapon dashing
|
||||
|
||||
public void ThrowWeapon()
|
||||
{
|
||||
_playerState.SendEvent("cancel_aim");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=157 format=3 uid="uid://bl5crtu1gkrtr"]
|
||||
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=160 format=3 uid="uid://bl5crtu1gkrtr"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cpplm41b5bt6m" path="res://addons/guide/guide_action_mapping.gd" id="1_qmhk6"]
|
||||
[ext_resource type="Resource" uid="uid://htqvokm8mufq" path="res://systems/inputs/base_mode/move.tres" id="2_g6bbx"]
|
||||
@@ -28,7 +28,7 @@
|
||||
[ext_resource type="Resource" uid="uid://d2r0ur8k3cuu3" path="res://systems/inputs/base_mode/dash.tres" id="23_g6bbx"]
|
||||
[ext_resource type="Script" uid="uid://dsa1dnifd6w32" path="res://addons/guide/guide_mapping_context.gd" id="23_llfhp"]
|
||||
[ext_resource type="Resource" uid="uid://bbce5wfwxpns1" path="res://systems/inputs/base_mode/slide_pressed.tres" id="23_rvpjj"]
|
||||
[ext_resource type="Resource" uid="uid://b334rau1yxmm7" path="res://systems/inputs/base_mode/slide.tres" id="25_s8kjn"]
|
||||
[ext_resource type="Resource" uid="uid://b334rau1yxmm7" path="res://systems/inputs/base_mode/slide_released.tres" id="25_rvpjj"]
|
||||
[ext_resource type="Resource" uid="uid://55b0dsvioj08" path="res://systems/inputs/base_mode/jump_pressed.tres" id="25_si4d4"]
|
||||
[ext_resource type="Resource" uid="uid://dgluj0ql5vth7" path="res://systems/inputs/base_mode/pause.tres" id="29_q86qg"]
|
||||
[ext_resource type="Script" uid="uid://cw71o87tvdx3q" path="res://addons/guide/inputs/guide_input_key.gd" id="30_cvxqo"]
|
||||
@@ -234,7 +234,7 @@ script = ExtResource("10_cvxqo")
|
||||
axis = 5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_st2ej"]
|
||||
script = ExtResource("15_fykw6")
|
||||
script = ExtResource("15_g6bbx")
|
||||
|
||||
[sub_resource type="Resource" id="Resource_s8kjn"]
|
||||
script = ExtResource("3_yp12v")
|
||||
@@ -246,10 +246,13 @@ metadata/_guide_triggers_collapsed = false
|
||||
script = ExtResource("30_cvxqo")
|
||||
key = 4194326
|
||||
|
||||
[sub_resource type="Resource" id="Resource_8ifoc"]
|
||||
script = ExtResource("15_g6bbx")
|
||||
|
||||
[sub_resource type="Resource" id="Resource_imjft"]
|
||||
script = ExtResource("3_yp12v")
|
||||
input = SubResource("Resource_wcvib")
|
||||
triggers = Array[ExtResource("8_2tfaw")]([SubResource("Resource_st2ej")])
|
||||
triggers = Array[ExtResource("8_2tfaw")]([SubResource("Resource_8ifoc")])
|
||||
metadata/_guide_triggers_collapsed = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_vibkn"]
|
||||
@@ -261,21 +264,29 @@ input_mappings = Array[ExtResource("3_yp12v")]([SubResource("Resource_s8kjn"), S
|
||||
script = ExtResource("10_cvxqo")
|
||||
axis = 5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_rvpjj"]
|
||||
script = ExtResource("17_s8kjn")
|
||||
|
||||
[sub_resource type="Resource" id="Resource_818lq"]
|
||||
script = ExtResource("3_yp12v")
|
||||
input = SubResource("Resource_f3pn5")
|
||||
triggers = Array[ExtResource("8_2tfaw")]([SubResource("Resource_rvpjj")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_qksfw"]
|
||||
script = ExtResource("30_cvxqo")
|
||||
key = 4194326
|
||||
|
||||
[sub_resource type="Resource" id="Resource_bhf7o"]
|
||||
script = ExtResource("17_s8kjn")
|
||||
|
||||
[sub_resource type="Resource" id="Resource_woy8j"]
|
||||
script = ExtResource("3_yp12v")
|
||||
input = SubResource("Resource_qksfw")
|
||||
triggers = Array[ExtResource("8_2tfaw")]([SubResource("Resource_bhf7o")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_2hs2y"]
|
||||
script = ExtResource("1_qmhk6")
|
||||
action = ExtResource("25_s8kjn")
|
||||
action = ExtResource("25_rvpjj")
|
||||
input_mappings = Array[ExtResource("3_yp12v")]([SubResource("Resource_818lq"), SubResource("Resource_woy8j")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_1fkas"]
|
||||
|
||||
@@ -22,8 +22,8 @@ class_name InputController
|
||||
@export var jump:GUIDEAction
|
||||
@export var jump_pressed:GUIDEAction
|
||||
@export_subgroup("Slide")
|
||||
@export var slide:GUIDEAction
|
||||
@export var slide_pressed:GUIDEAction
|
||||
@export var slide_released:GUIDEAction
|
||||
@export_subgroup("Other")
|
||||
@export var hit:GUIDEAction
|
||||
@export var parry:GUIDEAction
|
||||
@@ -48,7 +48,6 @@ signal input_aim_down
|
||||
signal input_aim_released
|
||||
|
||||
signal input_slide_started
|
||||
signal input_slide_ongoing
|
||||
signal input_slide_ended
|
||||
|
||||
signal input_hit
|
||||
@@ -68,8 +67,7 @@ func _ready() -> void:
|
||||
jump.completed.connect(on_input_jump_ended)
|
||||
|
||||
slide_pressed.triggered.connect(on_input_slide_started)
|
||||
slide.triggered.connect(on_input_slide_ongoing)
|
||||
slide.completed.connect(on_input_slide_ended)
|
||||
slide_released.triggered.connect(on_input_slide_ended)
|
||||
|
||||
hit.triggered.connect(on_input_hit)
|
||||
parry.triggered.connect(on_input_parry)
|
||||
@@ -102,8 +100,6 @@ func on_input_aim_released():
|
||||
|
||||
func on_input_slide_started():
|
||||
input_slide_started.emit()
|
||||
func on_input_slide_ongoing():
|
||||
input_slide_ongoing.emit()
|
||||
func on_input_slide_ended():
|
||||
input_slide_ended.emit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user