Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a1d57d6a1a | |||
| 941205af2b | |||
| 6c2ad89687 | |||
| 59494f9e98 | |||
| 510246c341 | |||
| b184bcdea5 | |||
| cf52af4237 | |||
| e0fc301414 | |||
| b792e8721c |
@@ -54,27 +54,12 @@ jobs:
|
||||
- name: Import resources and build solution
|
||||
run: |
|
||||
godot --headless --editor --build-solutions --quit --import --path $PWD
|
||||
|
||||
- name: Build Windows
|
||||
run: |
|
||||
mkdir -v -p build/windows
|
||||
godot --headless --verbose --build-solutions --export-release "Windows Desktop" build/windows/${{ env.GAME_NAME }}.exe
|
||||
zip -r Windows.zip build/windows
|
||||
- name: Build Windows ARM
|
||||
run: |
|
||||
mkdir -v -p build/windowsArm
|
||||
godot --headless --verbose --build-solutions --export-release "Windows ARM" build/windowsArm/${{ env.GAME_NAME }}.exe
|
||||
zip -r WindowsArm.zip build/windowsArm
|
||||
# - name: Linux Build
|
||||
# run: |
|
||||
# mkdir -v -p build/linux
|
||||
# godot --headless --verbose --export-release "Linux/X11" build/linux/${{ env.GAME_NAME }}.x86_64
|
||||
# zip -r Linux.zip build/linux
|
||||
- name: Mac Build
|
||||
run: |
|
||||
mkdir -v -p build/mac
|
||||
godot --headless --verbose --export-release "macOS" build/mac/${{ env.GAME_NAME }}.zip
|
||||
zip -r Mac.zip build/mac
|
||||
|
||||
- name: Upload to Itch
|
||||
uses: KikimoraGames/itch-publish@v0.0.3
|
||||
with:
|
||||
@@ -84,6 +69,12 @@ jobs:
|
||||
buildNumber: ${{ needs.BumpTag.outputs.tag_name }}
|
||||
gameData: Windows.zip
|
||||
buildChannel: windows
|
||||
|
||||
- name: Build Windows ARM
|
||||
run: |
|
||||
mkdir -v -p build/windowsArm
|
||||
godot --headless --verbose --build-solutions --export-release "Windows ARM" build/windowsArm/${{ env.GAME_NAME }}.exe
|
||||
zip -r WindowsArm.zip build/windowsArm
|
||||
- name: Upload to Itch
|
||||
uses: KikimoraGames/itch-publish@v0.0.3
|
||||
with:
|
||||
@@ -93,15 +84,27 @@ jobs:
|
||||
buildNumber: ${{ needs.BumpTag.outputs.tag_name }}
|
||||
gameData: WindowsArm.zip
|
||||
buildChannel: windows-arm
|
||||
# - name: Upload to Itch
|
||||
# uses: KikimoraGames/itch-publish@v0.0.3
|
||||
# with:
|
||||
# butlerApiKey: ${{ secrets.BUTLER_TOKEN }}
|
||||
# itchUsername: ${{ env.ITCHIO_USERNAME }}
|
||||
# itchGameId: ${{ env.ITCHIO_GAMEID }}
|
||||
# buildNumber: ${{ needs.BumpTag.outputs.tag_name }}
|
||||
# gameData: Linux.zip
|
||||
# buildChannel: linux
|
||||
|
||||
- name: Linux Build
|
||||
run: |
|
||||
mkdir -v -p build/linux
|
||||
godot --headless --verbose --export-release "Linux/X11" build/linux/${{ env.GAME_NAME }}.x86_64
|
||||
zip -r Linux.zip build/linux
|
||||
- name: Upload to Itch
|
||||
uses: KikimoraGames/itch-publish@v0.0.3
|
||||
with:
|
||||
butlerApiKey: ${{ secrets.BUTLER_TOKEN }}
|
||||
itchUsername: ${{ env.ITCHIO_USERNAME }}
|
||||
itchGameId: ${{ env.ITCHIO_GAMEID }}
|
||||
buildNumber: ${{ needs.BumpTag.outputs.tag_name }}
|
||||
gameData: Linux.zip
|
||||
buildChannel: linux
|
||||
|
||||
- name: Mac Build
|
||||
run: |
|
||||
mkdir -v -p build/mac
|
||||
godot --headless --verbose --export-release "macOS" build/mac/${{ env.GAME_NAME }}.zip
|
||||
zip -r Mac.zip build/mac
|
||||
- name: Upload to Itch
|
||||
uses: KikimoraGames/itch-publish@v0.0.3
|
||||
with:
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -1,8 +1,7 @@
|
||||
[gd_scene load_steps=41 format=3 uid="uid://dmkw8cmalm5k"]
|
||||
[gd_scene load_steps=40 format=3 uid="uid://dmkw8cmalm5k"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bei4nhkf8lwdo" path="res://player_controller/PlayerController.tscn" id="1_2vsi6"]
|
||||
[ext_resource type="Script" uid="uid://blenis2y55fmg" path="res://tools/city_helpers.gd" id="1_qwuk2"]
|
||||
[ext_resource type="Resource" uid="uid://bl5crtu1gkrtr" path="res://systems/inputs/base_mode/base_mode.tres" id="2_p287n"]
|
||||
[ext_resource type="Texture2D" uid="uid://ca4kkq3w8cd4n" path="res://assets/sky/sky_15_2k.png" id="2_ruo5i"]
|
||||
[ext_resource type="PackedScene" uid="uid://dkr80d2pi0d41" path="res://addons/guide/debugger/guide_debugger.tscn" id="2_uet8a"]
|
||||
[ext_resource type="Script" uid="uid://cyh0d64pfygbl" path="res://addons/maaacks_game_template/base/scripts/pause_menu_controller.gd" id="7_ukfuy"]
|
||||
@@ -92,7 +91,6 @@ adjustment_enabled = true
|
||||
|
||||
[node name="Main" type="Node3D"]
|
||||
script = ExtResource("1_qwuk2")
|
||||
base_mode = ExtResource("2_p287n")
|
||||
|
||||
[node name="BackgroundMusicPlayer" parent="." instance=ExtResource("9_i2xii")]
|
||||
stream = ExtResource("10_eca4n")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=47 format=3 uid="uid://bei4nhkf8lwdo"]
|
||||
[gd_scene load_steps=48 format=3 uid="uid://bei4nhkf8lwdo"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bbbrf5ckydfna" path="res://player_controller/Scripts/PlayerController.cs" id="1_poq2x"]
|
||||
[ext_resource type="PackedScene" uid="uid://cf3rrgr1imvv4" path="res://scenes/path/path.tscn" id="2_6lejt"]
|
||||
[ext_resource type="Resource" uid="uid://bl5crtu1gkrtr" path="res://systems/inputs/base_mode/base_mode.tres" id="3_cresl"]
|
||||
[ext_resource type="Resource" uid="uid://cpdaw41ah5gic" path="res://systems/inputs/base_mode/rotate_y.tres" id="4_rxwoh"]
|
||||
[ext_resource type="Resource" uid="uid://ccrb5xsnphc8" path="res://systems/inputs/base_mode/rotate_floorplane.tres" id="5_4u7i3"]
|
||||
@@ -62,21 +63,21 @@ blend_mode = 1
|
||||
[node name="Player" type="CharacterBody3D"]
|
||||
script = ExtResource("1_poq2x")
|
||||
WalkSpeed = 7.5
|
||||
AccelerationAir = 2.0
|
||||
DecelerationAir = 0.1
|
||||
Weight = 5.0
|
||||
AccelerationAir = 0.8
|
||||
DecelerationAir = 0.02
|
||||
Weight = 4.0
|
||||
MantleTime = 0.3
|
||||
MantlePath = ExtResource("2_6lejt")
|
||||
CoyoteTime = 0.3
|
||||
SimpleJumpStartVelocity = 8.0
|
||||
SimpleJumpStartVelocity = 6.0
|
||||
SimpleJumpHangTimeInFrames = 1
|
||||
SimpleJumpGravityLesseningFactor = 2.5
|
||||
DoubleJumpStartVelocity = 15.0
|
||||
SimpleJumpGravityLesseningFactor = 2.0
|
||||
DoubleJumpHangTimeInFrames = 3
|
||||
DoubleJumpGravityLesseningFactor = 1.5
|
||||
MegaJumpStartVelocity = 30.0
|
||||
MegaJumpHangTimeInFrames = 12
|
||||
MegaJumpGravityLesseningFactor = 1.2
|
||||
WallJumpStartVelocity = 12.0
|
||||
WallJumpStartVelocity = 8.0
|
||||
MaxNumberOfEmpoweredActions = 3
|
||||
SimpleDashStrength = 15.0
|
||||
PoweredDashStrength = 30.0
|
||||
@@ -234,6 +235,11 @@ transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 0
|
||||
mesh = SubResource("CylinderMesh_nodcl")
|
||||
|
||||
[node name="DashCooldown" type="Timer" parent="."]
|
||||
wait_time = 0.8
|
||||
one_shot = true
|
||||
|
||||
[node name="AirborneDashCooldown" type="Timer" parent="."]
|
||||
wait_time = 0.5
|
||||
one_shot = true
|
||||
|
||||
[node name="PowerCooldown" type="Timer" parent="."]
|
||||
@@ -250,6 +256,7 @@ offset_left = 1524.0
|
||||
offset_top = 1.0
|
||||
offset_right = -8.0
|
||||
offset_bottom = 1.0
|
||||
enabled = false
|
||||
initial_node_to_watch = NodePath("../StateChart")
|
||||
|
||||
[node name="UI" type="Control" parent="."]
|
||||
@@ -502,45 +509,45 @@ delay_in_seconds = "0.0"
|
||||
script = ExtResource("26_infe6")
|
||||
initial_state = NodePath("SimpleJump")
|
||||
|
||||
[node name="OnMantle" type="Node" parent="StateChart/Root/Movement/Jump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Mantling")
|
||||
event = &"mantle"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="SimpleJump" type="Node" parent="StateChart/Root/Movement/Jump"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnMegajump" type="Node" parent="StateChart/Root/Movement/Jump/SimpleJump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../MegaJump")
|
||||
event = &"megajump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnJumpEnded" type="Node" parent="StateChart/Root/Movement/Jump/SimpleJump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Airborne/DoubleJumpEnabled")
|
||||
event = &"jump_ended"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="DoubleJump" type="Node" parent="StateChart/Root/Movement/Jump"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnMegajump" type="Node" parent="StateChart/Root/Movement/Jump/DoubleJump"]
|
||||
[node name="OnMegajump" type="Node" parent="StateChart/Root/Movement/Jump/SimpleJump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../MegaJump")
|
||||
event = &"megajump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="DoubleJump" type="Node" parent="StateChart/Root/Movement/Jump"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnJumpEnded" type="Node" parent="StateChart/Root/Movement/Jump/DoubleJump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Airborne/Falling")
|
||||
event = &"jump_ended"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnMegajump" type="Node" parent="StateChart/Root/Movement/Jump/DoubleJump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../MegaJump")
|
||||
event = &"megajump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="MegaJump" type="Node" parent="StateChart/Root/Movement/Jump"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnJumpEnded" type="Node" parent="StateChart/Root/Movement/Jump/MegaJump"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Airborne/Falling")
|
||||
event = &"jump_ended"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="Dashing" type="Node" parent="StateChart/Root/Movement"]
|
||||
script = ExtResource("26_infe6")
|
||||
initial_state = NodePath("Dash")
|
||||
@@ -606,7 +613,7 @@ default_state = NodePath("../CoyoteEnabled")
|
||||
|
||||
[node name="OnWallRun" type="Node" parent="StateChart/Root/Movement/Airborne"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../OnWall/RunningCoyoteEnabled")
|
||||
to = NodePath("../../OnWall/Running")
|
||||
event = &"wall_run"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
@@ -669,7 +676,7 @@ script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnWallHug" type="Node" parent="StateChart/Root/Movement/Airborne/Falling"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../OnWall/HuggingCoyoteEnabled")
|
||||
to = NodePath("../../../OnWall/Hugging")
|
||||
event = &"wall_hug"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
@@ -707,6 +714,12 @@ to = NodePath("../../Airborne/Reset")
|
||||
event = &"start_falling"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnMantle" type="Node" parent="StateChart/Root/Movement/OnWall"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../Mantling")
|
||||
event = &"mantle"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="HuggingCoyoteEnabled" type="Node" parent="StateChart/Root/Movement/OnWall"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
@@ -727,7 +740,7 @@ script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/OnWall/Hugging"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Jump/SimpleJump")
|
||||
to = NodePath("../../../Jump/DoubleJump")
|
||||
event = &"jump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
@@ -736,7 +749,7 @@ script = ExtResource("27_34snm")
|
||||
|
||||
[node name="OnJump" type="Node" parent="StateChart/Root/Movement/OnWall/Hanging"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Jump/SimpleJump")
|
||||
to = NodePath("../../../Jump/DoubleJump")
|
||||
event = &"jump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
@@ -755,6 +768,12 @@ to = NodePath("../../Running")
|
||||
event = &"coyote_expired"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnLeaveWall" type="Node" parent="StateChart/Root/Movement/OnWall/RunningCoyoteEnabled"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Airborne/CoyoteEnabled")
|
||||
event = &"start_falling"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="Running" type="Node" parent="StateChart/Root/Movement/OnWall"]
|
||||
script = ExtResource("27_34snm")
|
||||
|
||||
@@ -764,6 +783,12 @@ to = NodePath("../../../Jump/SimpleJump")
|
||||
event = &"jump"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[node name="OnLeaveWall" type="Node" parent="StateChart/Root/Movement/OnWall/Running"]
|
||||
script = ExtResource("28_n7qhm")
|
||||
to = NodePath("../../../Airborne/CoyoteEnabled")
|
||||
event = &"start_falling"
|
||||
delay_in_seconds = "0.0"
|
||||
|
||||
[connection signal="input_aim_canceled" from="InputController" to="." method="OnInputAimCanceled"]
|
||||
[connection signal="input_aim_down" from="InputController" to="." method="OnInputAimDown"]
|
||||
[connection signal="input_aim_pressed" from="InputController" to="." method="OnInputAimPressed"]
|
||||
|
||||
@@ -58,6 +58,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
// Timers
|
||||
private Timer _timeScaleAimInAirTimer;
|
||||
private Timer _simpleDashCooldownTimer;
|
||||
private Timer _airborneDashCooldownTimer;
|
||||
private Timer _powerCooldownTimer;
|
||||
|
||||
[Export] public Marker3D TutorialWeaponTarget;
|
||||
@@ -81,6 +82,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
[ExportGroup("Mantle")]
|
||||
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
|
||||
public float MantleTime { get; set; } = 0.1f;
|
||||
[Export]
|
||||
public PackedScene MantlePath { get; set; }
|
||||
|
||||
// Jump
|
||||
[ExportGroup("Jump")]
|
||||
@@ -186,6 +189,11 @@ public partial class PlayerController : CharacterBody3D
|
||||
private bool _canDash = true;
|
||||
private bool _shouldMantleOnDashEnded;
|
||||
|
||||
private Vector3 _wallHugStartLocation = Vector3.Zero;
|
||||
private Vector3 _wallHugStartNormal = Vector3.Zero;
|
||||
private Vector3 _wallHugStartProjectedVelocity = Vector3.Zero;
|
||||
private Vector3 _currentWallContactPoint = Vector3.Zero;
|
||||
|
||||
private StateChart _playerState;
|
||||
|
||||
private StateChartState _aiming;
|
||||
@@ -197,7 +205,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
private StateChartState _grounded;
|
||||
private StateChartState _airborne;
|
||||
private StateChartState _coyoteEnabled;
|
||||
private StateChartState _doubleJumpEnabled;
|
||||
// private StateChartState _doubleJumpEnabled;
|
||||
private StateChartState _simpleJump;
|
||||
private StateChartState _doubleJump;
|
||||
private StateChartState _megaJump;
|
||||
@@ -218,9 +226,12 @@ public partial class PlayerController : CharacterBody3D
|
||||
private Transition _onJumpFromWall2;
|
||||
private Transition _onJumpFromWall3;
|
||||
private Transition _onMegajumpFromWall;
|
||||
private Transition _onLeaveWallFromRunCoyote;
|
||||
private Transition _onLeaveWallFromRun;
|
||||
|
||||
private float _playerHeight;
|
||||
private float _playerRadius;
|
||||
private bool _isJumpInputPressed;
|
||||
|
||||
private float _lookSensitivityMultiplier = 1.0f;
|
||||
private float _mouseSensitivityMultiplier = 1.0f;
|
||||
@@ -294,7 +305,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
_grounded = StateChartState.Of(GetNode("StateChart/Root/Movement/Grounded"));
|
||||
_airborne = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne"));
|
||||
_coyoteEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/CoyoteEnabled"));
|
||||
_doubleJumpEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/DoubleJumpEnabled"));
|
||||
// _doubleJumpEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/Airborne/DoubleJumpEnabled"));
|
||||
_simpleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/SimpleJump"));
|
||||
_doubleJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/DoubleJump"));
|
||||
_megaJump = StateChartState.Of(GetNode("StateChart/Root/Movement/Jump/MegaJump"));
|
||||
@@ -311,10 +322,13 @@ public partial class PlayerController : CharacterBody3D
|
||||
_onWallHanging = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/Hanging"));
|
||||
_onWallRunning = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/Running"));
|
||||
_onWallRunningCoyoteEnabled = StateChartState.Of(GetNode("StateChart/Root/Movement/OnWall/RunningCoyoteEnabled"));
|
||||
_onLeaveWallFromRun = Transition.Of(GetNode("StateChart/Root/Movement/OnWall/Running/OnLeaveWall"));
|
||||
_onLeaveWallFromRunCoyote = Transition.Of(GetNode("StateChart/Root/Movement/OnWall/RunningCoyoteEnabled/OnLeaveWall"));
|
||||
// State timers
|
||||
_powerCooldownTimer = GetNode<Timer>("PowerCooldown");
|
||||
_timeScaleAimInAirTimer = GetNode<Timer>("TimeScaleAimInAir");
|
||||
_simpleDashCooldownTimer = GetNode<Timer>("DashCooldown");
|
||||
_airborneDashCooldownTimer = GetNode<Timer>("AirborneDashCooldown");
|
||||
|
||||
///////////////////////////
|
||||
// Initialize components //
|
||||
@@ -351,6 +365,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
_grounded.StateEntered += OnGrounded;
|
||||
_grounded.StatePhysicsProcessing += HandleGrounded;
|
||||
_airborne.StatePhysicsProcessing += HandleAirborne;
|
||||
_onWall.StatePhysicsProcessing += HandleOnWall;
|
||||
|
||||
_coyoteEnabled.StateEntered += StartCoyoteTime;
|
||||
_timeScaleAimInAirTimer.Timeout += ResetTimeScale;
|
||||
@@ -385,6 +400,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
_aimedDash.StateExited += OnAimedDashFinished;
|
||||
|
||||
_simpleDashCooldownTimer.Timeout += DashCooldownTimeout;
|
||||
_airborneDashCooldownTimer.Timeout += AirborneDashCooldownTimeout;
|
||||
|
||||
_onWall.StateEntered += OnWallStarted;
|
||||
_onWall.StateExited += OnWallStopped;
|
||||
@@ -402,6 +418,8 @@ public partial class PlayerController : CharacterBody3D
|
||||
_onJumpFromWall2.Taken += OnJumpFromWall;
|
||||
_onJumpFromWall3.Taken += OnJumpFromWall;
|
||||
_onMegajumpFromWall.Taken += OnMegajumpFromWall;
|
||||
_onLeaveWallFromRun.Taken += OnLeaveWallFromRun;
|
||||
_onLeaveWallFromRunCoyote.Taken += OnLeaveWallFromRun;
|
||||
}
|
||||
|
||||
public void SetAllowedInputsAll()
|
||||
@@ -454,10 +472,25 @@ public partial class PlayerController : CharacterBody3D
|
||||
{
|
||||
_canDash = true;
|
||||
}
|
||||
public void AirborneDashCooldownTimeout()
|
||||
{
|
||||
_canDashAirborne = true;
|
||||
}
|
||||
|
||||
public bool IsPlayerInputtingForward()
|
||||
{
|
||||
return GetMoveInput().Z < -0.5f;
|
||||
}
|
||||
|
||||
public bool IsTryingToMantle()
|
||||
{
|
||||
return MantleSystem.IsMantlePossible && IsPlayerInputtingForward() && _isJumpInputPressed;
|
||||
}
|
||||
|
||||
public void HandleGrounded(float delta)
|
||||
{
|
||||
MoveOnGround(delta);
|
||||
// if (IsTryingToMantle()) _playerState.SendEvent("mantle");
|
||||
if (!isOnFloorCustom())
|
||||
_playerState.SendEvent("start_falling");
|
||||
}
|
||||
@@ -468,8 +501,13 @@ public partial class PlayerController : CharacterBody3D
|
||||
if (isOnFloorCustom())
|
||||
_playerState.SendEvent("grounded");
|
||||
|
||||
if (IsTryingToMantle()) _playerState.SendEvent("mantle");
|
||||
|
||||
if (!WallHugSystem.IsWallHugging())
|
||||
{
|
||||
_isWallJumpAvailable = true; // reset wall jump if we left the wall
|
||||
return;
|
||||
}
|
||||
|
||||
// Going upwards, we stay simply airborne
|
||||
if (Velocity.AngleTo(Vector3.Up) < Math.PI / 4)
|
||||
@@ -497,6 +535,11 @@ public partial class PlayerController : CharacterBody3D
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleOnWall(float delta)
|
||||
{
|
||||
if (IsTryingToMantle()) _playerState.SendEvent("mantle");
|
||||
}
|
||||
|
||||
public void OnWallHuggingStarted()
|
||||
{
|
||||
GetTree().CreateTimer(CoyoteTime).Timeout += CoyoteExpired;
|
||||
@@ -507,11 +550,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
GetTree().CreateTimer(CoyoteTime).Timeout += CoyoteExpired;
|
||||
}
|
||||
|
||||
private Vector3 _wallHugStartLocation = Vector3.Zero;
|
||||
private Vector3 _wallHugStartNormal = Vector3.Zero;
|
||||
private Vector3 _wallHugStartProjectedVelocity = Vector3.Zero;
|
||||
private Vector3 _currentWallContactPoint = Vector3.Zero;
|
||||
|
||||
public void OnWallDetected()
|
||||
{
|
||||
FinishPoweredDash();
|
||||
@@ -520,6 +558,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
return;
|
||||
|
||||
var newWallNormal = WallHugSystem.WallHugNormal.UnwrapOr(Vector3.Up);
|
||||
if (newWallNormal.AngleTo(_wallHugStartNormal) > Mathf.Pi/4) return;
|
||||
_wallHugStartNormal = newWallNormal;
|
||||
}
|
||||
|
||||
@@ -537,6 +576,11 @@ public partial class PlayerController : CharacterBody3D
|
||||
public void OnWallStopped()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnLeaveWallFromRun()
|
||||
{
|
||||
SimpleDashInDirection(Velocity.Normalized());
|
||||
}
|
||||
|
||||
public void HandleWallHugging(float delta)
|
||||
{
|
||||
@@ -591,10 +635,11 @@ public partial class PlayerController : CharacterBody3D
|
||||
Velocity = Vector3.Zero;
|
||||
GlobalPosition = _wallHugStartLocation;
|
||||
}
|
||||
|
||||
|
||||
// Jump
|
||||
public void OnInputJumpStarted()
|
||||
{
|
||||
_isJumpInputPressed = true;
|
||||
if (MantleSystem.IsMantlePossible)
|
||||
{
|
||||
_playerState.SendEvent("mantle");
|
||||
@@ -607,19 +652,22 @@ public partial class PlayerController : CharacterBody3D
|
||||
return;
|
||||
}
|
||||
|
||||
if (_onWallHuggingCoyoteEnabled.Active || _onWallRunningCoyoteEnabled.Active)
|
||||
{
|
||||
if (!_isWallJumpAvailable) return;
|
||||
}
|
||||
if (_onWall.Active && !_isWallJumpAvailable && IsFacingWall()) return;
|
||||
_playerState.SendEvent("jump");
|
||||
}
|
||||
|
||||
public bool IsFacingWall()
|
||||
{
|
||||
return _wallHugStartNormal.Dot(GetGlobalForwardFacingVector()) < -0.5f;
|
||||
}
|
||||
|
||||
public void OnInputJumpOngoing()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnInputJumpEnded()
|
||||
{
|
||||
_isJumpInputPressed = false;
|
||||
_playerState.SendEvent("jump_ended");
|
||||
}
|
||||
|
||||
@@ -635,7 +683,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
public void OnDoubleJumpStarted()
|
||||
{
|
||||
_canDash = true;
|
||||
_canDashAirborne = true;
|
||||
// _canDashAirborne = true;
|
||||
OnJumpStarted(DoubleJumpStartVelocity);
|
||||
}
|
||||
public void OnMegaJumpStarted()
|
||||
@@ -667,7 +715,14 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
public void OnJumpFromWall()
|
||||
{
|
||||
ComputeJumpFromWallHSpeed(WallJumpStartVelocity);
|
||||
if (!IsFacingWall())
|
||||
{
|
||||
ComputeJumpFromWallHSpeed(WallJumpStartVelocity);
|
||||
}
|
||||
// Remove the ability to dash straight away so you cannot scale up the wall
|
||||
_canDashAirborne = false;
|
||||
_airborneDashCooldownTimer.Start();
|
||||
_isWallJumpAvailable = false;
|
||||
}
|
||||
public void OnMegajumpFromWall()
|
||||
{
|
||||
@@ -725,38 +780,70 @@ public partial class PlayerController : CharacterBody3D
|
||||
z: velocity.Y);
|
||||
}
|
||||
|
||||
private Path _mantlePath;
|
||||
private bool _customMantle;
|
||||
private Transform3D _customMantleStartTransform;
|
||||
private Curve3D _customMantleCurve;
|
||||
private Vector3 _mantleStartPosition;
|
||||
public void OnMantleStarted()
|
||||
{
|
||||
HeadSystem.OnMantle();
|
||||
|
||||
_preMantleVelocity = Velocity;
|
||||
|
||||
_mantlePath = MantlePath.Instantiate() as Path;
|
||||
if (_mantlePath == null)
|
||||
{
|
||||
GD.PrintErr("Failed to instantiate MantlePath");
|
||||
return;
|
||||
}
|
||||
|
||||
var transform = _customMantle ? _customMantleStartTransform : MantleSystem.GlobalTransform;
|
||||
var curve = _customMantle ? _customMantleCurve : MantleSystem.MantleCurve;
|
||||
GetTree().GetRoot().AddChild(_mantlePath);
|
||||
_mantlePath.Setup(transform, curve);
|
||||
_mantleStartPosition = GlobalPosition;
|
||||
|
||||
var tween = GetTree().CreateTween();
|
||||
tween.SetTrans(Tween.TransitionType.Cubic);
|
||||
tween.SetTrans(Tween.TransitionType.Linear);
|
||||
tween.SetEase(Tween.EaseType.InOut);
|
||||
var inbetweenDuration = MantleTime / MantleSystem.NumberOfValidPofiles;
|
||||
for (int i = 0; i < MantleSystem.NumberOfValidPofiles; i += 1)
|
||||
{
|
||||
var position = MantleSystem.WallProfilePositions[i];
|
||||
tween.TweenProperty(this, "global_position", position, inbetweenDuration);
|
||||
}
|
||||
|
||||
tween.TweenProperty(_mantlePath.PathFollow, "progress_ratio", 1, MantleTime);
|
||||
tween.Finished += MantleFinished;
|
||||
}
|
||||
|
||||
public void HandleMantling(float delta)
|
||||
{
|
||||
|
||||
GlobalPosition = _mantlePath.Target.GlobalPosition;
|
||||
}
|
||||
|
||||
public void SimpleDashInDirection(Vector3 direction)
|
||||
{
|
||||
SetVelocity(direction * SimpleDashStrength);
|
||||
}
|
||||
|
||||
public void SimpleDash()
|
||||
{
|
||||
SimpleDashInDirection(GetInputGlobalHDirection());
|
||||
}
|
||||
|
||||
public void MantleFinished()
|
||||
{
|
||||
Velocity = _preMantleVelocity;
|
||||
_mantlePath.Teardown();
|
||||
var isThereMovementInput = GetMoveInput().Length() > 0;
|
||||
if (isThereMovementInput)
|
||||
{
|
||||
// If there's a movement input on Mantle, we dash in the direction the mantle took place
|
||||
var positionDifference = GlobalPosition - _mantleStartPosition;
|
||||
var directionHorizontal = new Vector3(positionDifference.X, 0, positionDifference.Z);
|
||||
SimpleDashInDirection(directionHorizontal.Normalized());
|
||||
}
|
||||
|
||||
_customMantle = false;
|
||||
_playerState.SendEvent("grounded");
|
||||
}
|
||||
|
||||
public void HandleJump(float delta, float gravityFactor, int hangFrames)
|
||||
{
|
||||
if (IsTryingToMantle()) _playerState.SendEvent("mantle");
|
||||
|
||||
// Update horizontal velocity
|
||||
var horizontalVelocity = ComputeHVelocityAir(delta);
|
||||
Velocity = new Vector3(horizontalVelocity.X, Velocity.Y, horizontalVelocity.Z);
|
||||
@@ -986,9 +1073,7 @@ public partial class PlayerController : CharacterBody3D
|
||||
|
||||
public void RecoverWeapon()
|
||||
{
|
||||
GetTree().GetRoot().RemoveChild(WeaponRoot);
|
||||
AddChild(WeaponRoot);
|
||||
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
||||
RecoverChildNode(WeaponRoot);
|
||||
WeaponSystem.ResetWeapon();
|
||||
}
|
||||
|
||||
@@ -1006,7 +1091,6 @@ public partial class PlayerController : CharacterBody3D
|
||||
}
|
||||
|
||||
private Vector3 _preDashVelocity = Vector3.Zero;
|
||||
|
||||
public void OnAimedDashStarted()
|
||||
{
|
||||
// Adjusting for player height, where the middle of the capsule should get to the dash location instead of the
|
||||
@@ -1020,9 +1104,10 @@ public partial class PlayerController : CharacterBody3D
|
||||
var dashTween = CreatePositionTween(correctedLocation, AimedDashTime);
|
||||
// dashTween.TweenMethod(Callable.From<float>(AimedDashTweenOngoing), 0.0f, 1.0f, AimedDashTime);
|
||||
dashTween.Finished += AimedDashTweenEnded;
|
||||
|
||||
_shouldMantleOnDashEnded = DashSystem.ShouldMantle;
|
||||
_mantleLocation = DashSystem.PlannedMantleLocation;
|
||||
|
||||
_customMantle = DashSystem.ShouldMantle;
|
||||
_customMantleCurve = DashSystem.MantleSystem.MantleCurve;
|
||||
_customMantleStartTransform = DashSystem.MantleSystem.GlobalTransform;
|
||||
}
|
||||
|
||||
Tween CreatePositionTween(Vector3 targetLocation, float tweenTime)
|
||||
@@ -1041,6 +1126,13 @@ public partial class PlayerController : CharacterBody3D
|
||||
_playerState.SendEvent("dash_finished");
|
||||
}
|
||||
|
||||
public void OnAimedDashFinished()
|
||||
{
|
||||
var postDashVelocity = _preDashVelocity.Length() > PostDashSpeed ? PostDashSpeed : _preDashVelocity.Length();
|
||||
Velocity = _dashDirection * postDashVelocity;
|
||||
if (_customMantle) _playerState.SendEvent("mantle");
|
||||
}
|
||||
|
||||
public void PlaceWeaponForTutorial()
|
||||
{
|
||||
if (TutorialDone)
|
||||
@@ -1051,14 +1143,25 @@ public partial class PlayerController : CharacterBody3D
|
||||
WeaponRoot.CallDeferred(Node3D.MethodName.SetGlobalPosition, TutorialWeaponTarget.GlobalPosition);
|
||||
WeaponSystem.CallDeferred(WeaponSystem.MethodName.PlaceWeaponForTutorial, TutorialWeaponTarget.GlobalPosition);
|
||||
}
|
||||
|
||||
public void RemoveChildNode(Node3D node)
|
||||
{
|
||||
RemoveChild(node);
|
||||
GetTree().GetRoot().AddChild(node);
|
||||
node.SetGlobalPosition(GlobalPosition);
|
||||
}
|
||||
|
||||
public void RecoverChildNode(Node3D node)
|
||||
{
|
||||
GetTree().GetRoot().RemoveChild(node);
|
||||
AddChild(node);
|
||||
node.SetGlobalPosition(GlobalPosition);
|
||||
}
|
||||
|
||||
public void ThrowWeapon()
|
||||
{
|
||||
_playerState.SendEvent("cancel_aim");
|
||||
|
||||
RemoveChild(WeaponRoot);
|
||||
GetTree().GetRoot().AddChild(WeaponRoot);
|
||||
WeaponRoot.SetGlobalPosition(GlobalPosition);
|
||||
RemoveChildNode(WeaponRoot);
|
||||
|
||||
var weaponTargetLocation = DashSystem.HasHit ? DashSystem.CollisionPoint : DashSystem.PlannedLocation;
|
||||
WeaponSystem.ThrowWeapon(
|
||||
@@ -1068,29 +1171,12 @@ public partial class PlayerController : CharacterBody3D
|
||||
DashSystem.CollisionNormal);
|
||||
}
|
||||
|
||||
public void OnAimedDashFinished()
|
||||
{
|
||||
var postDashVelocity = _preDashVelocity.Length() > PostDashSpeed ? PostDashSpeed : _preDashVelocity.Length();
|
||||
Velocity = _dashDirection * postDashVelocity;
|
||||
|
||||
if (_shouldMantleOnDashEnded)
|
||||
{
|
||||
// TODO update post dash mantle
|
||||
// MantleToLocation(_mantleLocation);
|
||||
GD.Print("update post dash mantle");
|
||||
}
|
||||
}
|
||||
|
||||
public void OnSimpleDashStarted()
|
||||
{
|
||||
if (!_canDash)
|
||||
return;
|
||||
_canDash = false;
|
||||
|
||||
var dashStrength = SimpleDashStrength;
|
||||
|
||||
var direction = GetInputGlobalHDirection();
|
||||
SetVelocity(direction * dashStrength);
|
||||
SimpleDash();
|
||||
}
|
||||
|
||||
public void HandleSimpleDash(float delta)
|
||||
@@ -1298,6 +1384,11 @@ public partial class PlayerController : CharacterBody3D
|
||||
{
|
||||
WeaponRoot.SetRotation(HeadSystem.Rotation);
|
||||
}
|
||||
|
||||
public Vector3 GetGlobalForwardFacingVector()
|
||||
{
|
||||
return Transform.Basis * HeadSystem.Transform.Basis * Vector3.Forward;
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
// Processes //////////////
|
||||
|
||||
25
scenes/path/Path.cs
Normal file
25
scenes/path/Path.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Godot;
|
||||
|
||||
public partial class Path : Path3D
|
||||
{
|
||||
public PathFollow3D PathFollow { get; private set; }
|
||||
public Marker3D Target { get; private set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
PathFollow = GetNode<PathFollow3D>("PathFollow");
|
||||
Target = GetNode<Marker3D>("PathFollow/Target");
|
||||
}
|
||||
|
||||
public void Setup(Transform3D globalTransform, Curve3D curve)
|
||||
{
|
||||
SetGlobalTransform(globalTransform);
|
||||
SetCurve(curve);
|
||||
PathFollow.ProgressRatio = 0;
|
||||
}
|
||||
|
||||
public void Teardown()
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
1
scenes/path/Path.cs.uid
Normal file
1
scenes/path/Path.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://djdr5bvfc8f0x
|
||||
13
scenes/path/path.tscn
Normal file
13
scenes/path/path.tscn
Normal file
@@ -0,0 +1,13 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://cf3rrgr1imvv4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://djdr5bvfc8f0x" path="res://scenes/path/Path.cs" id="1_kmlhi"]
|
||||
|
||||
[sub_resource type="Curve3D" id="Curve3D_u4rfr"]
|
||||
|
||||
[node name="Path" type="Path3D"]
|
||||
curve = SubResource("Curve3D_u4rfr")
|
||||
script = ExtResource("1_kmlhi")
|
||||
|
||||
[node name="PathFollow" type="PathFollow3D" parent="."]
|
||||
|
||||
[node name="Target" type="Marker3D" parent="PathFollow"]
|
||||
@@ -20,10 +20,10 @@ public partial class DashSystem: Node3D
|
||||
|
||||
public bool ShouldMantle { get; set; }
|
||||
public Vector3 PlannedMantleLocation { get; set; }
|
||||
public MantleSystem MantleSystem { get; set; }
|
||||
|
||||
private Node3D _head;
|
||||
private ShapeCast3D _dashCast3D;
|
||||
private ShapeCast3D _playerCast3D;
|
||||
private Camera3D _camera;
|
||||
private Vector3 _dashDirection = Vector3.Zero;
|
||||
|
||||
@@ -31,7 +31,6 @@ public partial class DashSystem: Node3D
|
||||
private MeshInstance3D _dashDropIndicator;
|
||||
private MeshInstance3D _dashDropLocationIndicator;
|
||||
|
||||
private MantleSystem _mantleSystem;
|
||||
private MeshInstance3D _dashTarget;
|
||||
private CpuParticles3D _dashIndicator;
|
||||
private AnimationPlayer _dashIndicatorAnim;
|
||||
@@ -47,9 +46,6 @@ public partial class DashSystem: Node3D
|
||||
public delegate void DashProgressEventHandler(float progress);
|
||||
|
||||
private Vector3 _globalDashPosition = Vector3.Zero;
|
||||
|
||||
private float _playerHeight;
|
||||
private float _playerRadius;
|
||||
|
||||
public float DashCastRadius { get; set; }
|
||||
|
||||
@@ -65,16 +61,11 @@ public partial class DashSystem: Node3D
|
||||
_dashDropLocationIndicator = GetNode<MeshInstance3D>("DashDropLocationIndicator");
|
||||
_dashDropLocationIndicator.Visible = false;
|
||||
|
||||
_playerCast3D = GetNode<ShapeCast3D>("PlayerShapeCast3D");
|
||||
var playerShape = _playerCast3D.GetShape() as CapsuleShape3D;
|
||||
_playerHeight = playerShape!.Height;
|
||||
_playerRadius = playerShape!.Radius;
|
||||
|
||||
_head = head;
|
||||
_camera = camera;
|
||||
|
||||
_mantleSystem = GetNode<MantleSystem>("MantleSystem");
|
||||
_mantleSystem.Init();
|
||||
MantleSystem = GetNode<MantleSystem>("MantleSystem");
|
||||
MantleSystem.Init();
|
||||
|
||||
_dashTarget = GetNode<MeshInstance3D>("DashTarget");
|
||||
_dashTarget.SetVisible(false);
|
||||
@@ -109,14 +100,15 @@ public partial class DashSystem: Node3D
|
||||
|
||||
(HasHit, PlannedLocation, CollisionPoint, CollisionNormal) = ComputeDashLocation();
|
||||
|
||||
ShouldMantle = false;
|
||||
var mantleLocation = Vector3.Zero;
|
||||
if (HasHit && Mathf.Abs(CollisionNormal.Y) < 0.5f)
|
||||
{
|
||||
var mantleResult = _mantleSystem.FindMantleLocationAtPoint(PlannedLocation, CollisionNormal);
|
||||
ShouldMantle = mantleResult.IsSome(out mantleLocation);
|
||||
}
|
||||
PlannedMantleLocation = mantleLocation;
|
||||
// TODO: Position mantle system to planned location, aligned with ground planned and facing the same way as the dash
|
||||
// Then query it being careful when dashing underneath a platform and such
|
||||
MantleSystem.SetGlobalPosition(PlannedLocation);
|
||||
MantleSystem.SetRotation(new Vector3(
|
||||
MantleSystem.Rotation.X,
|
||||
_head.Rotation.Y,
|
||||
MantleSystem.Rotation.Z));
|
||||
MantleSystem.ProcessMantle(false);
|
||||
ShouldMantle = MantleSystem.IsMantlePossible;
|
||||
|
||||
// Setup dash target
|
||||
var targetColor = HasHit ? new Color(1f, 0.2f, 0.2f) : new Color(1f, 1f, 1f);
|
||||
@@ -124,7 +116,7 @@ public partial class DashSystem: Node3D
|
||||
var targetMaterial = (StandardMaterial3D) _dashTarget.GetSurfaceOverrideMaterial(0);
|
||||
targetMaterial.SetAlbedo(targetColor);
|
||||
_dashTarget.SetVisible(true);
|
||||
var targetLocation = ShouldMantle ? PlannedMantleLocation : PlannedLocation;
|
||||
var targetLocation = ShouldMantle ? MantleSystem.FirstMantleProfilePoint : PlannedLocation;
|
||||
_dashTarget.SetGlobalPosition(targetLocation);
|
||||
|
||||
var shouldShowDropIndicator = !HasHit && !ShouldMantle;
|
||||
@@ -160,6 +152,5 @@ public partial class DashSystem: Node3D
|
||||
public void StartPreparingDash()
|
||||
{
|
||||
_dashTarget.SetVisible(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://cqduhd4opgwvm"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://cqduhd4opgwvm"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dwoppk8j5fxeg" path="res://systems/dash/DashSystem.cs" id="1_hwig2"]
|
||||
[ext_resource type="Shape3D" uid="uid://keseacdcooot" path="res://player_controller/resources/PlayerShape.tres" id="2_jngg2"]
|
||||
[ext_resource type="PackedScene" uid="uid://wq1okogkhc5l" path="res://systems/mantle/mantle_system.tscn" id="2_pff7b"]
|
||||
[ext_resource type="PackedScene" uid="uid://hd0868f4pb63" path="res://systems/dash/dash_indicator.tscn" id="2_tqt6i"]
|
||||
|
||||
@@ -24,16 +23,8 @@ outer_radius = 0.5
|
||||
script = ExtResource("1_hwig2")
|
||||
DashIndicatorScene = ExtResource("2_tqt6i")
|
||||
|
||||
[node name="PlayerShapeCast3D" type="ShapeCast3D" parent="."]
|
||||
visible = false
|
||||
shape = ExtResource("2_jngg2")
|
||||
target_position = Vector3(0, 0, 0)
|
||||
collision_mask = 2
|
||||
debug_shape_custom_color = Color(0.863327, 0.636844, 0, 1)
|
||||
|
||||
[node name="DashCast3D" type="ShapeCast3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0)
|
||||
visible = false
|
||||
shape = SubResource("SphereShape3D_jngg2")
|
||||
target_position = Vector3(0, 0, -12)
|
||||
max_results = 1
|
||||
@@ -42,7 +33,6 @@ debug_shape_custom_color = Color(0.911631, 0.11884, 0.656218, 1)
|
||||
|
||||
[node name="DashCastDrop" type="ShapeCast3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0, 1.6, 0)
|
||||
visible = false
|
||||
shape = SubResource("SphereShape3D_jngg2")
|
||||
target_position = Vector3(0, 0, -50)
|
||||
max_results = 1
|
||||
@@ -54,7 +44,6 @@ mesh = SubResource("SphereMesh_qu4wy")
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_v31n3")
|
||||
|
||||
[node name="MantleSystem" parent="." instance=ExtResource("2_pff7b")]
|
||||
visible = false
|
||||
MantleEndLocationDistanceFromWall = 0.25
|
||||
MantleHeightCastStart = 2.0
|
||||
|
||||
|
||||
@@ -14,17 +14,16 @@ public partial class MantleSystem: Node3D
|
||||
|
||||
private ShapeCast3D _wallInFrontCast3D;
|
||||
private ShapeCast3D _mantleCast3D;
|
||||
|
||||
|
||||
private ShapeCast3D _inAirWallDetect;
|
||||
private ShapeCast3D _groundedWallDetect;
|
||||
public Curve3D MantleCurve { get; private set; }
|
||||
public Vector3 FirstMantleProfilePoint { get; private set; } = Vector3.Zero;
|
||||
|
||||
public bool IsMantlePossible { get; private set; } = false;
|
||||
public int NumberOfValidPofiles { get; private set; } = -1;
|
||||
public const int WallProfileCastCount = 7;
|
||||
|
||||
private ShapeCast3D[] _wallProfileShapecasts = new ShapeCast3D[WallProfileCastCount];
|
||||
public Vector3[] WallProfilePositions { get; private set; } = new Vector3[WallProfileCastCount];
|
||||
public Vector3[] WallProfileNormals { get; private set; } = new Vector3[WallProfileCastCount];
|
||||
|
||||
public void Init()
|
||||
{
|
||||
@@ -55,22 +54,18 @@ public partial class MantleSystem: Node3D
|
||||
SetCastsEnabled(isColliding);
|
||||
|
||||
// Reset state
|
||||
NumberOfValidPofiles = -1;
|
||||
IsMantlePossible = false;
|
||||
if (!isColliding)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!isColliding) return;
|
||||
|
||||
// Check if collide with wall
|
||||
// Check if face something wall-like that should be climbable
|
||||
var collisionNormal = isGrounded ? _groundedWallDetect.GetCollisionNormal(0) : _inAirWallDetect.GetCollisionNormal(0);
|
||||
if (collisionNormal.Y > 0.8f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NumberOfValidPofiles = 0;
|
||||
var hasFirstProfileHit = false;
|
||||
if (collisionNormal.Y > 0.7f) return;
|
||||
|
||||
var spaceState = GetWorld3D().DirectSpaceState;
|
||||
MantleCurve = new Curve3D();
|
||||
MantleCurve.AddPoint(Vector3.Zero);
|
||||
var hasFirstProfileHit = false;
|
||||
var previousProfilePoint = GlobalPosition;
|
||||
foreach (var wallProfileShapecast in _wallProfileShapecasts)
|
||||
{
|
||||
// Haven't met the wall yet
|
||||
@@ -81,56 +76,34 @@ public partial class MantleSystem: Node3D
|
||||
// Got to the other side of the wall, we stop there
|
||||
if (!wallProfileShapecast.IsColliding())
|
||||
{
|
||||
WallProfilePositions[NumberOfValidPofiles] = globalTargetPosition;
|
||||
WallProfileNormals[NumberOfValidPofiles] = Vector3.Zero;
|
||||
NumberOfValidPofiles += 1;
|
||||
// MantleCurve.AddPoint(ToLocal(globalTargetPosition));
|
||||
break;
|
||||
}
|
||||
|
||||
var profilePoint = wallProfileShapecast.GetCollisionPoint(0);
|
||||
var profileNormal = wallProfileShapecast.GetCollisionNormal(0);
|
||||
var shape = wallProfileShapecast.Shape as SphereShape3D;
|
||||
var shapeRadius = shape == null ? 0.125f : shape.Radius;
|
||||
var centerOfShape = profilePoint + profileNormal * shapeRadius;
|
||||
|
||||
// Check if we collided parallel to a wall
|
||||
var isCollisionSameAsTarget = globalTargetPosition.IsEqualApprox(profilePoint);
|
||||
var isCollidingWithWall = profileNormal.Y < 0.9f;
|
||||
var isCollisionSameAsTarget = globalTargetPosition.IsEqualApprox(centerOfShape);
|
||||
var isCollidingWithWall = profileNormal.Y < 0.1f;
|
||||
if (isCollisionSameAsTarget || isCollidingWithWall) continue;
|
||||
|
||||
// Check if the path from the previous point makes us go through a wall
|
||||
var query = PhysicsRayQueryParameters3D.Create(previousProfilePoint, centerOfShape, wallProfileShapecast.CollisionMask);
|
||||
var result = spaceState.IntersectRay(query);
|
||||
if (result.Count > 0) break; // We are going through a wall, we stop there
|
||||
|
||||
// We have a valid collision
|
||||
WallProfilePositions[NumberOfValidPofiles] = profilePoint;
|
||||
WallProfileNormals[NumberOfValidPofiles] = profileNormal;
|
||||
if (!hasFirstProfileHit) FirstMantleProfilePoint = centerOfShape;
|
||||
hasFirstProfileHit = true;
|
||||
NumberOfValidPofiles += 1;
|
||||
}
|
||||
IsMantlePossible = NumberOfValidPofiles > 0; // Should always be true
|
||||
}
|
||||
|
||||
public Option<Vector3> FindMantle()
|
||||
{
|
||||
if (!_wallInFrontCast3D.IsColliding())
|
||||
{
|
||||
return Option<Vector3>.None;
|
||||
}
|
||||
if (_wallInFrontCast3D.GetCollisionNormal(0).Y > 0.8f)
|
||||
{
|
||||
return Option<Vector3>.None;
|
||||
previousProfilePoint = centerOfShape;
|
||||
MantleCurve.AddPoint(ToLocal(centerOfShape));
|
||||
}
|
||||
if (MantleCurve.PointCount == 1) return;
|
||||
|
||||
var collisionPoint = _wallInFrontCast3D.GetCollisionPoint(0);
|
||||
var collisionNormal = _wallInFrontCast3D.GetCollisionNormal(0);
|
||||
return FindMantleLocationAtPoint(collisionPoint, collisionNormal);
|
||||
}
|
||||
|
||||
public Option<Vector3> FindMantleLocationAtPoint(Vector3 point, Vector3 wallNormal)
|
||||
{
|
||||
var horizontalEndLocation = point - wallNormal * MantleEndLocationDistanceFromWall;
|
||||
var shapeCastStartLocation = horizontalEndLocation + Vector3.Up * MantleHeightCastStart;
|
||||
|
||||
_mantleCast3D.SetGlobalPosition(shapeCastStartLocation);
|
||||
var targetLocation = Vector3.Down * MantleHeightCastStart + Vector3.Up * MaxStepHeight;
|
||||
_mantleCast3D.SetTargetPosition(targetLocation);
|
||||
|
||||
if (_mantleCast3D.IsColliding() && _mantleCast3D.GetCollisionNormal(0).Y >= 0.1f)
|
||||
return Option.Some(_mantleCast3D.GetCollisionPoint(0));
|
||||
return Option<Vector3>.None;
|
||||
IsMantlePossible = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://wq1okogkhc5l"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://wq1okogkhc5l"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bja6tis1vaysu" path="res://systems/mantle/MantleSystem.cs" id="1_2oobp"]
|
||||
[ext_resource type="Shape3D" uid="uid://dp2p8v7demb5j" path="res://systems/mantle/find_wall_shape.tres" id="2_i32qj"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_4coqe"]
|
||||
height = 1.7
|
||||
@@ -9,6 +8,13 @@ height = 1.7
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_2oobp"]
|
||||
radius = 0.75
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_2oobp"]
|
||||
radius = 0.25
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_i32qj"]
|
||||
radius = 0.25
|
||||
height = 1.5
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_i32qj"]
|
||||
radius = 0.125
|
||||
|
||||
@@ -35,14 +41,14 @@ collision_mask = 2
|
||||
debug_shape_custom_color = Color(0.911631, 0.11884, 0.656218, 1)
|
||||
|
||||
[node name="InAirWallDetect" type="ShapeCast3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.26, 0)
|
||||
shape = ExtResource("2_i32qj")
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.01, 0)
|
||||
shape = SubResource("CapsuleShape3D_2oobp")
|
||||
target_position = Vector3(0, 0, -2)
|
||||
collision_mask = 2
|
||||
|
||||
[node name="GroundedWallDetect" type="ShapeCast3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.76, 0)
|
||||
shape = ExtResource("2_i32qj")
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.26, 0)
|
||||
shape = SubResource("CapsuleShape3D_i32qj")
|
||||
target_position = Vector3(0, 0, -2)
|
||||
collision_mask = 2
|
||||
|
||||
@@ -52,47 +58,47 @@ collision_mask = 2
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.5, -0.5)
|
||||
enabled = false
|
||||
shape = SubResource("SphereShape3D_i32qj")
|
||||
target_position = Vector3(0, -2.375, 0)
|
||||
target_position = Vector3(0, -2.125, 0)
|
||||
collision_mask = 2
|
||||
|
||||
[node name="ShapeCast2" type="ShapeCast3D" parent="WallProfileShapeCasts"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.5, -0.75)
|
||||
enabled = false
|
||||
shape = SubResource("SphereShape3D_i32qj")
|
||||
target_position = Vector3(0, -2.375, 0)
|
||||
target_position = Vector3(0, -2.125, 0)
|
||||
collision_mask = 2
|
||||
|
||||
[node name="ShapeCast3" type="ShapeCast3D" parent="WallProfileShapeCasts"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.5, -1)
|
||||
enabled = false
|
||||
shape = SubResource("SphereShape3D_i32qj")
|
||||
target_position = Vector3(0, -2.375, 0)
|
||||
target_position = Vector3(0, -2.125, 0)
|
||||
collision_mask = 2
|
||||
|
||||
[node name="ShapeCast4" type="ShapeCast3D" parent="WallProfileShapeCasts"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.5, -1.25)
|
||||
enabled = false
|
||||
shape = SubResource("SphereShape3D_i32qj")
|
||||
target_position = Vector3(0, -2.375, 0)
|
||||
target_position = Vector3(0, -2.125, 0)
|
||||
collision_mask = 2
|
||||
|
||||
[node name="ShapeCast5" type="ShapeCast3D" parent="WallProfileShapeCasts"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.5, -1.5)
|
||||
enabled = false
|
||||
shape = SubResource("SphereShape3D_i32qj")
|
||||
target_position = Vector3(0, -2.375, 0)
|
||||
target_position = Vector3(0, -2.125, 0)
|
||||
collision_mask = 2
|
||||
|
||||
[node name="ShapeCast6" type="ShapeCast3D" parent="WallProfileShapeCasts"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.5, -1.75)
|
||||
enabled = false
|
||||
shape = SubResource("SphereShape3D_i32qj")
|
||||
target_position = Vector3(0, -2.375, 0)
|
||||
target_position = Vector3(0, -2.125, 0)
|
||||
collision_mask = 2
|
||||
|
||||
[node name="ShapeCast7" type="ShapeCast3D" parent="WallProfileShapeCasts"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.5, -2)
|
||||
enabled = false
|
||||
shape = SubResource("SphereShape3D_i32qj")
|
||||
target_position = Vector3(0, -2.375, 0)
|
||||
target_position = Vector3(0, -2.125, 0)
|
||||
collision_mask = 2
|
||||
|
||||
Reference in New Issue
Block a user