This commit is contained in:
@@ -23,8 +23,6 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
||||
|
||||
[Export]
|
||||
public float JumpHeight { get; set; } = 5.5f;
|
||||
|
||||
private float PeakTime { get; set; } = 0.1f;
|
||||
|
||||
[ExportCategory("Max Speeds")]
|
||||
[Export]
|
||||
@@ -73,7 +71,7 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
||||
private float _lv = 0.0f;
|
||||
|
||||
private void RecalculateLv() {
|
||||
_lv = Mathf.Sqrt(Mathf.Pow(Gravity * PeakTime / 2, 2) + 2 * Gravity * JumpHeight);
|
||||
_lv = Mathf.Sqrt(Mathf.Pow(Gravity * 0.1f / 2, 2) + 2 * Gravity * JumpHeight);
|
||||
}
|
||||
|
||||
public override void _Ready() {
|
||||
@@ -151,7 +149,7 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
||||
vely *= 1/4f;
|
||||
}
|
||||
|
||||
if (Input.IsActionJustPressed("jump") && vely > 0) {
|
||||
if (Input.IsActionJustPressed("turn_back") && vely > 0) {
|
||||
var side = velx > 0 ? PredictiveCollisions.Location.BottomRight : PredictiveCollisions.Location.BottomLeft;
|
||||
if (Predictor.AnyHit(side) && !this.IsOnWall()) {
|
||||
EmitSignal(SignalName.OnTurnbackJump, true, this.IsOnWall());
|
||||
@@ -174,17 +172,31 @@ public partial class PlayerPhysicsController : CharacterBody2D {
|
||||
return true;
|
||||
});
|
||||
// has jump point
|
||||
float theta = Mathf.Atan2(-yAxis, xAxis);
|
||||
if (theta < 0) theta = 0;
|
||||
if (theta > Mathf.Pi / 2) theta = Mathf.Pi/2;
|
||||
Vector2 turnjump = new Vector2(Mathf.Cos(theta), -Mathf.Sin(theta) - 0.2f) * _lv;
|
||||
float theta = Mathf.Atan2(-yAxis, Mathf.Abs(xAxis));
|
||||
float margin = 20 * (Mathf.Pi / 180f);
|
||||
if (theta < margin) theta = margin;
|
||||
if (theta > Mathf.Pi / 2 - margin) theta = Mathf.Pi/2 - margin;
|
||||
Vector2 turnjump = new Vector2(-Mathf.Sign(velx) * Mathf.Cos(theta), -Mathf.Sin(theta) - 0.2f) * _lv;
|
||||
GD.Print($"Theta: {theta * (180 / Mathf.Pi)}, turnjump: {turnjump}");
|
||||
velx = turnjump.X;
|
||||
vely = turnjump.Y;
|
||||
} else {
|
||||
// does not have jump point
|
||||
// float theta = Mathf.Atan2(-yAxis, Mathf.Abs(xAxis));
|
||||
// float margin = 20 * (Mathf.Pi / 180f);
|
||||
// if (theta < margin) theta = margin;
|
||||
// if (theta > Mathf.Pi / 2 - margin) theta = Mathf.Pi/2 - margin;
|
||||
// Vector2 turnjump = new Vector2(-Mathf.Sign(Velocity.X) * Mathf.Cos(theta), -Mathf.Sin(theta) - 0.2f) * _lv;
|
||||
// GD.Print($"Theta: {theta * (180 / Mathf.Pi)}, turnjump: {turnjump}");
|
||||
// velx = turnjump.X;
|
||||
// vely = turnjump.Y;
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.IsActionJustPressed("jump") && Mathf.Abs(vely) < 2) {
|
||||
vely = -_lv;
|
||||
}
|
||||
|
||||
velx += xAxis * AirAcceleration * (float)delta;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user