Fixed cancellation logic; added double jump max fall speed property.
Release / Export Game (push) Successful in 2m3s

This commit is contained in:
qwsdcvghyu89
2026-06-14 21:29:15 +10:00
parent 4e344cc02d
commit 62f61acc10
3 changed files with 11 additions and 11 deletions
+1 -1
View File
@@ -216,7 +216,7 @@ script = ExtResource("2_oekxy")
WalkAcceleration = 30.0 WalkAcceleration = 30.0
StoppingDeceleration = 50.0 StoppingDeceleration = 50.0
CancellationAcceleration = 50.0 CancellationAcceleration = 50.0
AirAcceleration = 5.0 AirAcceleration = 3.0
MaxFallSpeed = 50.0 MaxFallSpeed = 50.0
MaxRiseSpeed = 50.0 MaxRiseSpeed = 50.0
MaxRunSpeed = 12.0 MaxRunSpeed = 12.0
+1
View File
@@ -11,6 +11,7 @@ config_version=5
[application] [application]
config/name="WrplatGodot" config/name="WrplatGodot"
config/version="0.1.38"
run/main_scene="uid://r2lb1ommvj6u" run/main_scene="uid://r2lb1ommvj6u"
config/features=PackedStringArray("4.6", "C#", "Forward Plus") config/features=PackedStringArray("4.6", "C#", "Forward Plus")
config/icon="res://icon.svg" config/icon="res://icon.svg"
+9 -10
View File
@@ -37,6 +37,8 @@ public partial class PlayerPhysicsController : CharacterBody2D {
private float MaxWalkSpeed { get; set; } = 8f; private float MaxWalkSpeed { get; set; } = 8f;
[Export] [Export]
private float MaxAirSpeed { get; set; } = 16f; private float MaxAirSpeed { get; set; } = 16f;
[Export]
private float MaxDoubleJumpFallSpeed { get; set; } = 1f;
[ExportCategory("Objects")] [ExportCategory("Objects")]
[Export] [Export]
@@ -193,7 +195,7 @@ public partial class PlayerPhysicsController : CharacterBody2D {
} }
} }
if (Input.IsActionJustPressed("jump") && Mathf.Abs(vely) < 2) { if (Input.IsActionJustPressed("jump") && Mathf.Abs(vely) < MaxDoubleJumpFallSpeed) {
vely = -_lv; vely = -_lv;
} }
@@ -209,18 +211,15 @@ public partial class PlayerPhysicsController : CharacterBody2D {
var maxXSpeed = grounded ? Input.IsActionPressed("run") ? MaxRunSpeed : MaxWalkSpeed : MaxAirSpeed; var maxXSpeed = grounded ? Input.IsActionPressed("run") ? MaxRunSpeed : MaxWalkSpeed : MaxAirSpeed;
var maxYSpeed = vely > 0 ? MaxFallSpeed : MaxRiseSpeed; var maxYSpeed = vely > 0 ? MaxFallSpeed : MaxRiseSpeed;
var (absvelx, absvely) = (Mathf.Abs(velx), Mathf.Abs(vely)); var (absvelx, absvely) = (Mathf.Abs(velx), Mathf.Abs(vely));
float xcancel = 0, ycancel = 0; if (absvelx > maxXSpeed)
if (absvelx > maxXSpeed) xcancel = -Math.Sign(velx) * CancellationAcceleration * (float)delta; velx = Mathf.Sign(velx) * Mathf.Max(absvelx - CancellationAcceleration * (float)delta, maxXSpeed);
if (absvely > maxYSpeed) ycancel = -Math.Sign(vely) * CancellationAcceleration * (float)delta; if (absvely > maxYSpeed)
if (Mathf.Abs(xcancel) + 0.1 > absvelx && xcancel != 0) velx = 0; vely = Mathf.Sign(vely) * Mathf.Max(absvely - CancellationAcceleration * (float)delta, maxYSpeed);
else velx += xcancel;
if (Mathf.Abs(ycancel) + 0.1 > absvely && ycancel != 0) vely = 0;
else vely += ycancel;
DebugTextLabel.Text = DebugTextLabel.Text =
$"grounded: {grounded}\n" + $"grounded: {grounded}\n" +
$"vely: (v+{ycancel}=){vely}\n" + $"vely: {vely}\n" +
$"velx: (v+{xcancel}=){velx}\n" + $"velx: {velx}\n" +
$"lv : {_lv:F2} or {_lv/(float)delta:F2}\n" + $"lv : {_lv:F2} or {_lv/(float)delta:F2}\n" +
$"lcrc : {Predictor.AnyHit(PredictiveCollisions.Location.BottomLeft)}/{Predictor.AnyHit(PredictiveCollisions.Location.BottomRight)}"; $"lcrc : {Predictor.AnyHit(PredictiveCollisions.Location.BottomLeft)}/{Predictor.AnyHit(PredictiveCollisions.Location.BottomRight)}";
// Force = new Vector2(0, forcey); // Force = new Vector2(0, forcey);