some shader work and improved mantle feel

This commit is contained in:
2026-01-11 17:09:58 +01:00
parent f2a39316ba
commit 1eb65d1520
13 changed files with 65 additions and 25 deletions

View File

@@ -66,7 +66,6 @@ WalkSpeed = 7.5
AccelerationAir = 0.8
DecelerationAir = 0.02
Weight = 4.0
MantleTime = 0.3
MantlePath = ExtResource("2_6lejt")
CoyoteTime = 0.3
InputBufferFrames = 5
@@ -257,10 +256,10 @@ 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="."]
visible = false
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
@@ -506,6 +505,12 @@ to = NodePath("../../Grounded")
event = &"grounded"
delay_in_seconds = "0.0"
[node name="OnMantleOtherSide" type="Node" parent="StateChart/Root/Movement/Mantling"]
script = ExtResource("28_n7qhm")
to = NodePath("../../OnWall/Hugging")
event = &"on_wall"
delay_in_seconds = "0.0"
[node name="Jump" type="Node" parent="StateChart/Root/Movement"]
script = ExtResource("26_infe6")
initial_state = NodePath("SimpleJump")

View File

@@ -801,6 +801,11 @@ public partial class PlayerController : CharacterBody3D
private Transform3D _customMantleStartTransform;
private Curve3D _customMantleCurve;
private Vector3 _mantleStartPosition;
private Vector3 _velocityOnMantleStarted = Vector3.Zero;
private bool _mantleEndedOnOtherSideOfWall = false;
private bool _mantleFoundGround = false;
public void OnMantleStarted()
{
HeadSystem.OnMantle();
@@ -811,17 +816,22 @@ public partial class PlayerController : CharacterBody3D
GD.PrintErr("Failed to instantiate MantlePath");
return;
}
_velocityOnMantleStarted = Velocity;
var transform = _customMantle ? _customMantleStartTransform : MantleSystem.GlobalTransform;
var curve = _customMantle ? _customMantleCurve : MantleSystem.MantleCurve;
_mantleEndedOnOtherSideOfWall = _customMantle ? _mantleEndedOnOtherSideOfWall : MantleSystem.EndedOnOtherSideOfWall;
_mantleFoundGround = _customMantle ? _mantleFoundGround : MantleSystem.FoundGround;
GetTree().GetRoot().AddChild(_mantlePath);
_mantlePath.Setup(transform, curve);
_mantleStartPosition = GlobalPosition;
var curveLength = curve.GetBakedLength();
var tween = GetTree().CreateTween();
tween.SetTrans(Tween.TransitionType.Linear);
tween.SetEase(Tween.EaseType.InOut);
tween.TweenProperty(_mantlePath.PathFollow, "progress_ratio", 1, MantleTime);
tween.SetEase(Tween.EaseType.In);
tween.TweenProperty(_mantlePath.PathFollow, "progress_ratio", 1, MantleTime*curveLength);
tween.Finished += MantleFinished;
}
@@ -843,13 +853,17 @@ public partial class PlayerController : CharacterBody3D
public void MantleFinished()
{
_mantlePath.Teardown();
// SetVelocity(_finalCurveDirection.Normalized() * _speedOverCurve);
var isThereMovementInput = GetMoveInput().Length() > 0;
if (isThereMovementInput)
{
// If there's a movement input on Mantle, we dash in the direction the mantle took place
// If there's a movement input on Mantle, we dash in the direction the mantle ended with
var positionDifference = GlobalPosition - _mantleStartPosition;
var directionHorizontal = new Vector3(positionDifference.X, 0, positionDifference.Z);
SimpleDashInDirection(directionHorizontal.Normalized());
// SimpleDashInDirection(directionHorizontal.Normalized());
SetVelocity(directionHorizontal.Normalized() * WalkSpeed);
}
_customMantle = false;
@@ -1124,6 +1138,8 @@ public partial class PlayerController : CharacterBody3D
_customMantle = DashSystem.ShouldMantle;
_customMantleCurve = DashSystem.MantleSystem.MantleCurve;
_customMantleStartTransform = DashSystem.MantleSystem.GlobalTransform;
_mantleEndedOnOtherSideOfWall = DashSystem.MantleSystem.EndedOnOtherSideOfWall;
_mantleFoundGround = DashSystem.MantleSystem.FoundGround;
}
Tween CreatePositionTween(Vector3 targetLocation, float tweenTime)