player behavior tweaks

This commit is contained in:
Lilith Schier 2026-08-01 20:34:53 +02:00
parent 5a6c711296
commit 17a807365b
2 changed files with 22 additions and 13 deletions

File diff suppressed because one or more lines are too long

View file

@ -182,7 +182,14 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
// Drag in water // Drag in water
if (IsInWater) if (IsInWater)
{ {
velocity += Physics.DragForce(-velocity, 0.02f) * deltaF; if (_currentDirection.IsZeroApprox() || IsHoldingWall)
{
velocity += Physics.DragForce(-velocity, 0.2f) * deltaF;
}
else
{
velocity += Physics.DragForce(-velocity, 0.015f) * deltaF;
}
} }
// Drag while in air // Drag while in air
else if (!IsOnFloor() && JumpTimer.IsStopped()) else if (!IsOnFloor() && JumpTimer.IsStopped())
@ -191,7 +198,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
} }
} }
if (IsHoldingWall()) if (IsHoldingWall)
{ {
velocity.Y = Mathf.Min(velocity.Y, 5.0f); velocity.Y = Mathf.Min(velocity.Y, 5.0f);
IsFacingRight = Mathf.Sign(GetWallNormal().X) > 0; IsFacingRight = Mathf.Sign(GetWallNormal().X) > 0;
@ -254,6 +261,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
public void OnLeftWater(Node2D body) public void OnLeftWater(Node2D body)
{ {
if (!IsInWater || SubmersedSensor.HasOverlappingBodies()) return; if (!IsInWater || SubmersedSensor.HasOverlappingBodies()) return;
GD.Print("leaving water");
IsInWater = false; IsInWater = false;
WaterJumpAllowedTimer.Start(); WaterJumpAllowedTimer.Start();
} }
@ -268,14 +276,11 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
private Vector2 FacingVector => IsFacingRight ? Vector2.Right : Vector2.Left; private Vector2 FacingVector => IsFacingRight ? Vector2.Right : Vector2.Left;
private bool IsHoldingWall() private bool IsHoldingWall =>
{
return
!IsOnFloor() !IsOnFloor()
&& IsOnWall() && IsOnWall()
&& Mathf.Sign(GetWallNormal().X) != Mathf.Sign(_currentDirection.X) && Mathf.Sign(GetWallNormal().X) != Mathf.Sign(_currentDirection.X)
&& _currentDirection.X != 0; && _currentDirection.X != 0;
}
public void OnProcess(double delta) public void OnProcess(double delta)
{ {
@ -383,7 +388,10 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
AdjustFacing(); AdjustFacing();
JumpAllowedTimer.Stop(); JumpAllowedTimer.Stop();
JumpTimer.Start(); JumpTimer.Start();
var direction = new Vector2(Mathf.Sign(GetWallNormal().X), -.5f).Normalized();
var wallDirection = (float)Mathf.Sign(GetWallNormal().X);
var upwardComponent = IsInWater ? 0f : -.4f;
var direction = new Vector2(wallDirection, upwardComponent).Normalized();
Velocity = direction * 200.0f; Velocity = direction * 200.0f;
} }