diff --git a/objects/scenes/demo/demo.tscn b/objects/scenes/demo/demo.tscn index 854b962..2f3f04d 100644 --- a/objects/scenes/demo/demo.tscn +++ b/objects/scenes/demo/demo.tscn @@ -216,7 +216,7 @@ script = ExtResource("2_oekxy") WalkAcceleration = 30.0 StoppingDeceleration = 50.0 CancellationAcceleration = 50.0 -AirAcceleration = 5.0 +AirAcceleration = 3.0 MaxFallSpeed = 50.0 MaxRiseSpeed = 50.0 MaxRunSpeed = 12.0 diff --git a/project.godot b/project.godot index 4b03aca..a2e2ec9 100644 --- a/project.godot +++ b/project.godot @@ -11,6 +11,7 @@ config_version=5 [application] config/name="WrplatGodot" +config/version="0.1.38" run/main_scene="uid://r2lb1ommvj6u" config/features=PackedStringArray("4.6", "C#", "Forward Plus") config/icon="res://icon.svg" diff --git a/src/components/PlayerPhysicsController.cs b/src/components/PlayerPhysicsController.cs index 5376b16..0c31990 100644 --- a/src/components/PlayerPhysicsController.cs +++ b/src/components/PlayerPhysicsController.cs @@ -37,6 +37,8 @@ public partial class PlayerPhysicsController : CharacterBody2D { private float MaxWalkSpeed { get; set; } = 8f; [Export] private float MaxAirSpeed { get; set; } = 16f; + [Export] + private float MaxDoubleJumpFallSpeed { get; set; } = 1f; [ExportCategory("Objects")] [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; } @@ -209,18 +211,15 @@ public partial class PlayerPhysicsController : CharacterBody2D { var maxXSpeed = grounded ? Input.IsActionPressed("run") ? MaxRunSpeed : MaxWalkSpeed : MaxAirSpeed; var maxYSpeed = vely > 0 ? MaxFallSpeed : MaxRiseSpeed; var (absvelx, absvely) = (Mathf.Abs(velx), Mathf.Abs(vely)); - float xcancel = 0, ycancel = 0; - if (absvelx > maxXSpeed) xcancel = -Math.Sign(velx) * CancellationAcceleration * (float)delta; - if (absvely > maxYSpeed) ycancel = -Math.Sign(vely) * CancellationAcceleration * (float)delta; - if (Mathf.Abs(xcancel) + 0.1 > absvelx && xcancel != 0) velx = 0; - else velx += xcancel; - if (Mathf.Abs(ycancel) + 0.1 > absvely && ycancel != 0) vely = 0; - else vely += ycancel; + if (absvelx > maxXSpeed) + velx = Mathf.Sign(velx) * Mathf.Max(absvelx - CancellationAcceleration * (float)delta, maxXSpeed); + if (absvely > maxYSpeed) + vely = Mathf.Sign(vely) * Mathf.Max(absvely - CancellationAcceleration * (float)delta, maxYSpeed); DebugTextLabel.Text = $"grounded: {grounded}\n" + - $"vely: (v+{ycancel}=){vely}\n" + - $"velx: (v+{xcancel}=){velx}\n" + + $"vely: {vely}\n" + + $"velx: {velx}\n" + $"lv : {_lv:F2} or {_lv/(float)delta:F2}\n" + $"lcrc : {Predictor.AnyHit(PredictiveCollisions.Location.BottomLeft)}/{Predictor.AnyHit(PredictiveCollisions.Location.BottomRight)}"; // Force = new Vector2(0, forcey);