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

View file

@ -182,7 +182,14 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
// Drag in water
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
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);
IsFacingRight = Mathf.Sign(GetWallNormal().X) > 0;
@ -254,6 +261,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
public void OnLeftWater(Node2D body)
{
if (!IsInWater || SubmersedSensor.HasOverlappingBodies()) return;
GD.Print("leaving water");
IsInWater = false;
WaterJumpAllowedTimer.Start();
}
@ -268,14 +276,11 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
private Vector2 FacingVector => IsFacingRight ? Vector2.Right : Vector2.Left;
private bool IsHoldingWall()
{
return
!IsOnFloor()
&& IsOnWall()
&& Mathf.Sign(GetWallNormal().X) != Mathf.Sign(_currentDirection.X)
&& _currentDirection.X != 0;
}
private bool IsHoldingWall =>
!IsOnFloor()
&& IsOnWall()
&& Mathf.Sign(GetWallNormal().X) != Mathf.Sign(_currentDirection.X)
&& _currentDirection.X != 0;
public void OnProcess(double delta)
{
@ -383,7 +388,10 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
AdjustFacing();
JumpAllowedTimer.Stop();
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;
}