Compare commits

..

4 Commits

Author SHA1 Message Date
510246c341 fix a scene load issue
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 21s
Create tag and build when new code gets to main / Export (push) Successful in 8m22s
2025-12-22 14:25:17 +01:00
b184bcdea5 added a small dash when leaving a wall run organically
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 18s
Create tag and build when new code gets to main / Export (push) Successful in 8m36s
2025-12-21 17:23:38 +01:00
cf52af4237 mantling after aimed dash with new mantle system 2025-12-21 16:44:35 +01:00
e0fc301414 fixed user stuff
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 17s
Create tag and build when new code gets to main / Export (push) Successful in 8m10s
2025-12-19 19:11:53 +01:00
6 changed files with 87 additions and 98 deletions

View File

@@ -139,7 +139,6 @@ theme_override_constants/margin_bottom = 10
[node name="TutoMoveAndLook" type="VBoxContainer" parent="TutorialController/PanelContainer/MarginContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
theme_override_constants/separation = 0
@@ -375,10 +374,9 @@ shadow_opacity = 0.95
shadow_blur = 2.435
[node name="Player" parent="." node_paths=PackedStringArray("TutorialWeaponTarget") instance=ExtResource("1_2vsi6")]
transform = Transform3D(0.054514527, 0, -0.9985129, 0, 1, 0, 0.9985129, 0, 0.054514527, -6, 75.5, -13.5)
transform = Transform3D(0.054514527, 0, -0.9985129, 0, 1, 0, 0.9985129, 0, 0.054514527, 0, -132.75, 118)
collision_layer = 17
TutorialWeaponTarget = NodePath("../PlacedTutorialWeapon/WeaponLocationTarget")
TutorialDone = true
AccelerationAir = 1.5
[node name="DebugLayer" type="CanvasLayer" parent="."]

View File

@@ -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"]
@@ -66,6 +67,7 @@ AccelerationAir = 2.0
DecelerationAir = 0.1
Weight = 5.0
MantleTime = 0.2
MantlePath = ExtResource("2_6lejt")
CoyoteTime = 0.3
SimpleJumpStartVelocity = 8.0
SimpleJumpHangTimeInFrames = 1
@@ -250,6 +252,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="."]
@@ -761,6 +764,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")
@@ -770,6 +779,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"]

View File

@@ -82,7 +82,7 @@ public partial class PlayerController : CharacterBody3D
[Export(PropertyHint.Range, "0,1,0.01,or_greater")]
public float MantleTime { get; set; } = 0.1f;
[Export]
public PackedScene MantlePath { get; set; } = GD.Load<PackedScene>("res://scenes/path/Path.tscn");
public PackedScene MantlePath { get; set; }
// Jump
[ExportGroup("Jump")]
@@ -225,10 +225,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 = false;
private bool _isJumpInputPressed;
private float _lookSensitivityMultiplier = 1.0f;
private float _mouseSensitivityMultiplier = 1.0f;
@@ -319,6 +321,8 @@ 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");
@@ -411,6 +415,8 @@ public partial class PlayerController : CharacterBody3D
_onJumpFromWall2.Taken += OnJumpFromWall;
_onJumpFromWall3.Taken += OnJumpFromWall;
_onMegajumpFromWall.Taken += OnMegajumpFromWall;
_onLeaveWallFromRun.Taken += OnLeaveWallFromRun;
_onLeaveWallFromRunCoyote.Taken += OnLeaveWallFromRun;
}
public void SetAllowedInputsAll()
@@ -538,6 +544,7 @@ public partial class PlayerController : CharacterBody3D
return;
var newWallNormal = WallHugSystem.WallHugNormal.UnwrapOr(Vector3.Up);
if (newWallNormal.AngleTo(_wallHugStartNormal) > Mathf.Pi/4) return;
_wallHugStartNormal = newWallNormal;
}
@@ -555,6 +562,11 @@ public partial class PlayerController : CharacterBody3D
public void OnWallStopped()
{
}
public void OnLeaveWallFromRun()
{
SimpleDashInDirection(Velocity.Normalized());
}
public void HandleWallHugging(float delta)
{
@@ -746,6 +758,10 @@ public partial class PlayerController : CharacterBody3D
}
private Path _mantlePath;
private bool _customMantle;
private Transform3D _customMantleStartTransform;
private Curve3D _customMantleCurve;
private Vector3 _mantleStartPosition;
public void OnMantleStarted()
{
HeadSystem.OnMantle();
@@ -755,10 +771,13 @@ public partial class PlayerController : CharacterBody3D
{
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(MantleSystem.GlobalTransform, MantleSystem.MantleCurve);
_mantlePath.Setup(transform, curve);
_mantleStartPosition = GlobalPosition;
var tween = GetTree().CreateTween();
tween.SetTrans(Tween.TransitionType.Linear);
@@ -772,14 +791,29 @@ public partial class PlayerController : CharacterBody3D
GlobalPosition = _mantlePath.Target.GlobalPosition;
}
public void SimpleDashInDirection(Vector3 direction)
{
SetVelocity(direction * SimpleDashStrength);
}
public void SimpleDash()
{
SimpleDashInDirection(GetInputGlobalHDirection());
}
public void MantleFinished()
{
_mantlePath.Teardown();
var direction = GetInputGlobalHDirection();
if (direction.Length() > 0)
var isThereMovementInput = GetMoveInput().Length() > 0;
if (isThereMovementInput)
{
SetVelocity(direction * SimpleDashStrength);
// 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");
}
@@ -1034,7 +1068,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
@@ -1048,9 +1081,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)
@@ -1069,6 +1103,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)
@@ -1107,29 +1148,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)

View File

@@ -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);
}
}

View File

@@ -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

View File

@@ -18,6 +18,7 @@ public partial class MantleSystem: Node3D
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 const int WallProfileCastCount = 7;
@@ -86,6 +87,7 @@ public partial class MantleSystem: Node3D
if (isCollisionSameAsTarget || isCollidingWithWall) continue;
// We have a valid collision
if (!hasFirstProfileHit) FirstMantleProfilePoint = profilePoint;
hasFirstProfileHit = true;
MantleCurve.AddPoint(ToLocal(profilePoint));
}
@@ -93,34 +95,4 @@ public partial class MantleSystem: Node3D
IsMantlePossible = true;
}
public Option<Vector3> FindMantle()
{
if (!_wallInFrontCast3D.IsColliding())
{
return Option<Vector3>.None;
}
if (_wallInFrontCast3D.GetCollisionNormal(0).Y > 0.8f)
{
return Option<Vector3>.None;
}
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;
}
}